When I use cin
to get a string from the user, then use getline()
after it, the compiler skips over getline()
and doesn't get input from the user.
cout << "What is your name: ";
string name;
cin >> name;
cout << "What is your favorite book: ";
string book;
getline(cin, book);
Output:
What is your name: Example Input
What is your favorite book:
Program exists
I tried using cin.ignore()
but I don't know what to put exactly in the parameters.