well, i'm writing a text-based game, and my 'NameEnter' function is acting up, basically, if you confirm that the name that you input is correct, it works fine, but if you type 'no' or something else, it doesn't accept the name reentry, i am not sure exactly what i have done wrong, but the outputs are below, and below that is the code. The name entered in all the examples is 'matthew'.
'yes' output let's begin, matthew
'no' output
Enter your name correctly this time: so, your name is , correct?
Just type 'yes' or 'no'
note: you are not prompted to reenter your name at all.
else output
Please enter 'yes' or 'no' - no capitals
Enter your name correctly this time: so, your name is ,correct?
Just type 'yes' or 'no's
note: you are not prompted to reenter your name at all.
void NameEnter () {
//declerations start
string PlrName;
getline(cin , PlrName);
string (PlrNameConfirm);
//declerations end
cout << "So, your name is " << PlrName << " ,correct?" << endl;
cout << "\n";
cout << "Just type 'yes' or 'no'" << endl;
cin >> PlrNameConfirm;
do
if (PlrNameConfirm == "yes") {
cout << "\n";
cout << "let's begin, " << PlrName << endl;
// below here is the problem//
} else if (PlrNameConfirm == "no") {
cout << "Enter your name correctly this time: ";
getline(cin , PlrName);
cout << "so, your name is " << PlrName << " ,correct?" << endl;
cout << "\n";
cout << "Just type 'yes' or 'no'";
cin >> PlrNameConfirm;
} else {
cout << "Please enter 'yes' or 'no' - no capitals" << endl;
cout << "\n";
cout << "Enter your name correctly this time: ";
getline(cin , PlrName);
cout << "so, your name is " << PlrName << " ,correct?" << endl;
cout << "\n";
cout << "Just type 'yes' or 'no'";
cin >> PlrNameConfirm;
}
while (PlrNameConfirm != "yes");
// above here is the problem //
}