I can't figure out why this isn't working, please help. I'm trying to use the getLine() function to have the user enter the command "read note" to read the note1 string. Here is a small section of my program where I believe the problem is:
1 2 3 4 5 6 7 8
while(true){
cout << "\nWhat do you want to do? " << endl;
getline(cin,choice);
if(choice == "read note"){
cout << "The note reads: \"" << note1 << "\"";
break;
}else cout << "Invalid Entry. Commands are: read, move\n";
}
For some reason, when I run the code it says "Invalid Entry. Commands are: read, move" before I type anything. It allows me to enter the next time though. Please help me fix this problem.
What you said worked Disch, but now that I added more commands that don't break from the loop, the getLine is returning nothing after one of those commands even with the cin.ignore(100, '\n') which is in that loop.