Is there a way of limiting scanf in C?
问题 I am trying to write a correct console application for linked list usage, so i need to scan a number of a command in a infinite loop and do something due to switch case option. So i am using scanf for this but the problem is when the next line doesnt contain number it loops and starts printing not even default value. `while(1) { printf("Enter a number of a command.\n"); scanf("%d",&command); switch(command) { case -1: .... default: printf("Reenter command.\n"); break; } } It seems like when i