ProgrammingVery hard

char s[] = "\x41\x42\0\x43"; printf("%zu", strlen(s)); What is printed?

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

Correct answer: D. 2

strlen stops at the first zero byte, which the \0 escape creates after the two hex-escaped letters. The C after it is never counted, although sizeof(s) is 5.

More C Programming questions

Exams that ask this topic