I'm trying to get user input for a function. The following code works, but not when there is a space between words.
string cityNew;
string cityPrevious;
cout<<"Enter a city name:"<<endl;
cin>>cityNew;
cout<<"Enter a previous city name:"<<endl;
cin>>cityPrevious;
comNet.addCity(cityPrevious, cityNew);
I've attempted using getline(cin,cityNew)
but this causes both cout
statements to print before allowing for the user to input anything.