I have the following code:
int data = 0;
cout << "Enter a number: ";
cin >> data;
cout << "You entered " << data << endl;
string str;
cout << "Enter a string: ";
getline(cin,str);
cout << "Your entered " << str << endl;
After getting the first prompt, I entered a valid number 10. But as soon as I hit return, the program output:
You entered 10 Enter a string: Your entered
In other words, it didn't ask for the second string input. What happened?
Thanks