+ 2
Why cin method in cpp dont take spaces as input?
When i declare a string 's' in cpp and then gets input by cin and let user enters : ram 45 cat then cin only get ram not spaces and characters after it?
3 Answers
+ 5
If using getline(), make sure you know which one you're using.
c++ string in <string>
http://www.cplusplus.com/reference/string/string/getline/
c string (char* array) in <iostream>
http://www.cplusplus.com/reference/istream/istream/getline/
+ 3
Use: getline(cin,s);
+ 2
'cin' is the functions which gets input till it reads a space, so to get the characters after space we generally use gets function.