Soldato
- Joined
- 19 Oct 2002
- Posts
- 2,707
- Location
- UK
I have to take a number of inputs which must be positive and not exceed a short int, I have been told 'the user must be able to bash their hands on the keyboard and throw the computer out of the window and your program must not break'
I did the following...
But when I put anything in that isn't a number it goes into an infinite loop and I'm not sure why or how to fix it.

Code:
do {
printf("Enter value for x (0-32768): ");
scanf("%d", &x);
} while( (x < 0)||(x > 32768) );
But when I put anything in that isn't a number it goes into an infinite loop and I'm not sure why or how to fix it.