ProgrammingHard

char d[4] = "abc"; printf("%zu", sizeof d - strlen(d)); What is printed?

  1. A. 1
  2. B. 0
  3. C. 3
  4. D. 4

Correct answer: A. 1

sizeof d is 4, strlen is 3, so the result is 1. This counts the spare bytes after the string, which is zero only when the terminator fills the array.

More C Programming questions

Exams that ask this topic