#include <stdio.h>
main()
{
int c ;
while ((c = getchar()) != EOF)
{
int isEOF = (c==EOF);
printf("is %c EOF: %d ", c, isEOF);
}
}
Why printf() method is called twice on every input char here?
If i give a input 'a', I am getting the result like
E:C_workouts>gcc CharIO.c -o CharIO.exe
E:C_workouts>CharIO.exe
a
is a EOF: 0 is
EOF: 0
The same happens on every input.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…