I'm having issues with the getline() function.
The code is on a different computer so to save typing time variable names and cout'ed strings are not excact except for the placement of the \n. The code goes something like this:
but the output looks like this:Code:#include <string> #include <otherNeededheader(s)> using std::string; using std::cout; using std::cin or endl or what other crap you see here; //not exact ;-) ... string s1; string s2; string s3; cout<<"\n Please enter something: "; getline(cin, s1); cout<<"\n\n Please enter something else: "; getline(cin, s2); cout<<"\n Please enter something else: "; getline(cin, s3); cout<<"\nSomething else!!!\n\n"; cout<< "s1: " << s1 <<endl; cout<< "s2: " << s2 <<endl; cout<< "s3: " << s3 <<endl;
btw 'wtf' stands for 'what the fudge'... in case you were curiousCode:Please enter something: Please enter something else: why does user input start here??? Please enter something else: wtf??? wtf??? Something else!!! s1: s2: why does user input start here??? s3: wtf??? wtf???
Can anyone tell me why the program is skipping the first getline command?
Thank you for being patient with me.
(I'm using Dev c++ 4.9.9.2)



LinkBack URL
About LinkBacks



