When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
8 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
now the problem here is in this error handling
(could not post it as text as i dont have discord nitro)
{
int choice = 1;
int createChoice = 1;
do
{
cout << "choose" << endl;
cout << "1. create" << endl;
cout << "2. update" << endl;
cout << "0. exit" << endl;
cin >> choice;
if (choice != 1 || choice != 2 || choice != 0){
cout << "Invalid try again" << endl;
}
else if (cin.fail()){
cin.clear();
cin.ignore();
cout << "Invalid try again" << endl;
continue;
}
switch (choice)
{
case 1:
create(createChoice);
break;
case 2:
update();
break;
}
} while (choice != 0);
return 0;
}```
When i input a letter in cin >> choice
shouldnt it say "Invalid try again" and loop back to the menu? however it just stops at saying "Invalid try again"
@sharp onyx
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.