Skip to the task
Layout
Back to classic view

You are looking at lesson 11. Your place is still Practice test 1, task 1: About.

CHECKTask 15 of 20 · step 6: Drills: check yourself

while (!feof)

The file has the lines first and second. What does this loop print?

char line[20];
while (!feof(f)) {
    fgets(line, sizeof line, f);
    printf("> %s", line);
}
Stuck?

> first, > second, > second: the third fgets fails and line keeps the old line. Correct: while (fgets(...) != NULL).