First, sorry for my bad english, okay go to this question above. I was surfing a lot for reference about this question on many websites, but i didn't find the right answer yet.
I'm trying to make a C program which this program can determine if the user input an integer or not, if user didn't input an integer then the program retry prompt to user for input an integer and so on. Everything is ok when i use scanf() return value on conditional statement, but the problem is, when user input 'whitespace/blankspace/space' (on ascii code as  ) and press 'enter', my program just stay running to wait for user input some characters or integer.
I just wish that if the input is 'whitespace/blackspace/space', the program will repeat prompt to user to input an integer or the program just stop.
Here is the case code :
#include <stdio.h>
int main() {
int number, isInt;
printf("Input a number : ");
do {
if ((isInt = scanf("%d", &number)) == 0) {
printf("retry : ");
scanf("%*s");
} else if (number < 0) {
printf("retry : ");
}
} while (isInt == 0 || number < 0);
printf("%d\n", number);
return 0;
}
I am a newbie in C, and curious about this. I know if i use %[^\n] <-- code format for scanf() string and convert it to integer, the program that i mean will run correctly. Is there another way to solve this using %d code format? or using scanf() ?
Please help me to break my curiosity, Regards :D