Hi,
I've got a problem.
I have a program that ask for a number to the user.
If the user put a letter instead of a number the program crashes (loop).
How can I prevent this ?
I've tried with isdigit but with no results.
int choise;
cout << "\nChoose one: ";
cin >> setw(sizeof(choice)) >> choise;
if(isdigit(choice)) cout <<"all ok";
if(isalpha(choice)) cout<<"error - number needed";
but the code doesn't work.
=(
Thanks to all.
--
oooO Oooo
( ) YUS ( )
\ ( Para todos, todo, ) /
\_ ) nada para nosotros. ( _/