I'm using MSVC++ and am getting this problem: I'm asking the user to enter a string that may or may not contain a space using the following code:
The problem is that the user has to press the enter key twice and I'm not sure how to avoid that. I've tried using cin.sync() and cin.ignore(100, '\n') before and after the getline, but they don't work. The program works fine, whatever the user enters before the first enter goes into the string, and nothing is recorded if anything is entered BETWEEN the first and second enter. Anyone know what I can do to fix this?Code:string city, team; cout<<"What do you want the city name to be? --> "; getline(cin, city); cout<<"What do you want the team name to be? --> "; getline(cin, team);