August 2011
Intermediate to advanced
552 pages
23h 48m
English
Take a look at the central loop in main:
while (!feof(stdin)) {
Loop over the body of the while statement until the standard-in stream indicates that it has reached EOF (end of file). End of file happens when you explicitly type Control-D on a new line if you are typing text into the program. When in a pipeline, the standard-in stream will be closed when the program writing to it exits or otherwise closes the outgoing pipe on its end.
const size_t length = fread (buffer, 1, BUFFER_SIZE, stdin);
Read in no more than BUFFER_SIZE bytes. The fread() function is a record-oriented function that you'll see more of in
Read now
Unlock full access