ProgrammingHard

char line[6]; fgets(line, sizeof line, stdin); /* stdin holds the text 12345678 followed by a newline */ printf("%zu", strlen(line)); What is printed?

  1. A. 6
  2. B. 4
  3. C. 8
  4. D. 5

Correct answer: D. 5

fgets stores at most five characters plus the terminator, so the string is 12345 with length 5.

More C Programming questions

Exams that ask this topic