Code:
string name;
cout << "Please Key in your full name: " << endl;
getline(cin, name);
cout << endl;
cout <<"Hello ";
|
Go4Expert Member
|
|
| 7Oct2009,21:44 | #1 |
|
Hey guys, when I type my code to getline(cin,name); it skips this line of the code
Code:
string name;
cout << "Please Key in your full name: " << endl;
getline(cin, name);
cout << endl;
cout <<"Hello ";
|
|
Mentor
|
![]() |
| 8Oct2009,00:31 | #2 |
|
Works fine for me in Visual Studio 2008; made a small change to confirm name contains the expected value:
Code:
string name; cout << "Please Key in your full name: " << endl; getline(cin, name); cout << endl; cout <<"Hello "<<name<<endl; Please Key in your full name: Fred Hello Fred |
|
Go4Expert Member
|
|
| 8Oct2009,19:37 | #3 |
|
Thanks for the help
. But I have the code cout << name << endl; below that line. Not sure why it did not work. But I fixed it by asking the user to type in his first and last name seperately
|