ProgrammingModerate

char w[] = "ab"; printf("%zu %zu", sizeof w, strlen(w)); What is printed (on any platform)?

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

Correct answer: A. 3 2

sizeof counts the terminator too, so the array has 3 bytes. strlen counts only the characters.

More C Programming questions

Exams that ask this topic