Why does scanf appear to skip input?
I am confused about scanf's behaviour in the following program. scanf appears to input once, and then not input again, until a stream of characters is printed. Below in a C program #include<stdio.h> int main() { int i, j=0; do { ++j; scanf("%d", &i); printf("\n\n%d %d\n\n", i, j); } while((i!=8) && (j<10)); printf("\nJ = %d\n", j); return 0; } here, Till i am inputting any integer program works perfectly fine, but when a character is inputted it goes on printing the last inputed value of i and never stops(untill j is 10 when loop exits) for scanf to take next input. output:: 1 <-----1st input