ProgrammingModerate

char *names[] = {"x", "yy", "zzz"}; printf("%zu", strlen(names[2])); What is printed?

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

Correct answer: A. 3

names[2] points at "zzz", and strlen counts its 3 characters but not the terminator. 4 adds the '\0', and 2 reads names[1] by an off-by-one slip.

More C Programming questions

Exams that ask this topic