0

trying to do input checking for an alpha character inputted where a numeric one is needed. I've implemented this function firstChoice() to allow a certain response is '2' or '3' was picked and then another certain response for anything other than '0 '1' '2' or '3'. I must add another check to see if the number is an alpha character. From what I've read, both isdigit() and isalpha() use 'char' types, but for my sitation i need 'choice' as an integer type...any suggestions?:?:?:

```
int firstChoice()
{
int choice;
cin >> choice;
if (choice==1 || choice==0)
{
return choice;
}
while(choice!=0 && choice !=1)
{
if (choice == 2 || choice == 3)
{
cout << "Enter the polynomial first\n0. Quit\n1. Enter polynomial\n2. Print polynomial\n3. Integrate\n\nEnter your choice : ";
cin >> choice;
}
if (choice != 0 && choice != 1 && choice != 2 && choice != 3)
{
cout << "'" << choice << "'is an invalid choice\nEnter your choice : ";
cin >> choice;
}
}
if (choice==1 || choice==0)
{
return choice;
}
}
```

SAMPLE OUTPUT (what i want is in red, other is already fitted into code):

```
Enter your choice : 2
'2' is an invalid choice
0. (option 0)
1. (option 1)
2. (option 2)
3. (option 3)
Enter your choice : 9
'9' is an invalid choice
Enter your choice : w
'w' is an invalid choice
Enter your choice :
```

*Edited 6 Years Ago by gnarlyskim*: n/a