| billywilliam (33) | |
|
I went to the page for the string class (the page that gives information on all of the functions/members/templates of the class in detail) and I wasn't able to make sense of it. I also went to the source code for the string class and I was even more lost. Just don't yell at me for not giving it my best shot before I came here, fellas. I've recently given c-style array strings the finger, because I don't like them, so now I'm moving to the string class. I'm having trouble reading input into a string variable. the declaration obviously goes like string strInput;and the code that I use to fetch input looks like cin >> strInput;As soon as the input includes a space (the 32 integer equivalent, NOT an underscore/'_'), everything before the space gets read into strInput, and everything after the space gets dumped into "cyberspace," never to be seen again. At first I thought I might try 'cin.getline(30,strInput)' but I'm not sure if that's a good idea. Thoughts?Suggestions? Thanks for reading. | |
|
|
|
| vlad from moscow (3662) | |
|
Use std::getline( std::cin, strInput ); As for your original problem then you should use several statements std::cin >> strInput; to read the whole statement. | |
|
|
|