ProgrammingHard

char z[6] = "ab\0cd"; printf("%zu", strlen(z)); What is printed?

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

Correct answer: D. 2

The embedded \0 terminates the string after ab, so strlen is 2 even though the array holds more bytes.

More C Programming questions

Exams that ask this topic