void choiceSelect()
{
int choice;
char exitconfirm[100];
printmenu();
cin >> choice;
if (isdigit(choice))
{
if (choice == 7)
{
cout << "Exiting program. Enter yes to confirm.\n";
cin.ignore();
cin.getline (exitconfirm, 100, '\n');
if (strcmp ("yes", exitconfirm) == 0)
{
exit (1);
}
else
{
choiceSelect();
}
}
while (choice != 7)
{
if (choice == 1)
cout << "1";
else if (choice == 2)
cout << "2";
else if (choice == 3)
cout << "3";
else if (choice == 4)
cout << "4";
else if (choice == 5)
cout << "5";
else if (choice == 6)
cout << "6";
else
choiceSelect();
}
}
else
{
cout <<"error!!!";
cin.ignore();
choiceSelect();
}
}
Hi, I need some help with my assignment yet again. This time, it's just a simple recursive loop that I can't get working.
I've done most parts but I can't figure out why the "isdigit" isn't working. I want the program to detect if the user inputs anything other than numbers.
If I understand correctly,
if (isdigit(choice))
if choice = numbers, it'll run the program since it's true. However, it doesn't, Instead it runs the else part.
Can anyone point me in the right direction. Appreciate the help:$