I'm reading The C Programming Language and have understood everything so far.
However when I came across the getchar()
and putchar()
, I failed to understand what is their use, and more specifically, what the following code does.
main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
I understand the main()
function, the declaration of the integer c
and the while
loop. Yet I'm confused about the condition inside of the while
loop. What is the input in this C code, and what is the output.
Sorry if this is a basic and stupid question, but I'm just looking for a simple explanation before I move on in the book and become more confused.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…