ProgrammingModerate

printf("%zu", strlen("a b c")); What is printed?

  1. A. 7
  2. B. 6
  3. C. 3
  4. D. 1

Correct answer: B. 6

strlen counts every character before the '\0', spaces included: a, space, b, space, space, c = 6. 7 adds the terminator as sizeof would, 3 counts only the letters, and 1 stops at the first space as scanf's %s would.

More C Programming questions

Exams that ask this topic