0
can someone explain how to use char to print out the character with space.. such as a person name... for example John Cena...
i have tried to code in c++ the john cena name... but the cout is only John... can someone help me... i tried the header of cstring.. but i dont know how it worked.. for those who replied i really appreciate it.. (:
7 Antworten
+ 7
cin ignores every thing after space, which means it keeps reading until it encounters any whitespace.
So in order to tackle that problem we use getline() function which also handles whitespaces(spaces and tabs).
0
cout << "John Cena";
0
oh soory..
0
i mean that..
char name[32]
cin>>name;
cout<<name
0
the output is only john
0
Im not a C++ expert so I looked about and the problem is with cin and the easiest way I found was to use a string and the getline() function...
string name;
getline(cin, name);
cout >> name;
0
oh.. thank you All