cruel
Programmer
- Aug 6, 2001
- 131
Hi, I am not a c programmer by training. So, the following must be some thing very basic to a lot fo you. I simply try to allow users to identify a list of variables between item A and item B. From the reference I have, in 'switch' the choice can only be integer. The following piece works OK if users enter 0-9. But, everything is messed if users type anything else. The "invalid reply" warning will be looping on the screen forever. Thanks
...
printf( "Mark the variable ('1 for item A, 0 for item B')? " );
scanf( "%i", &choice );
while ( !( choice == 1 || choice == 2 ) ) {
printf( "Invalid reply. Number '1' or '2' only. Re-enter: "
scanf( "%i", &choice );
}
switch ( choice ) {
case 1:
...
...
printf( "Mark the variable ('1 for item A, 0 for item B')? " );
scanf( "%i", &choice );
while ( !( choice == 1 || choice == 2 ) ) {
printf( "Invalid reply. Number '1' or '2' only. Re-enter: "
scanf( "%i", &choice );
}
switch ( choice ) {
case 1:
...