ProgrammingVery hard

printf("%d", strlen("a\0b")); What is printed?

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

Correct answer: D. 1

The \0 escape ends the string after 'a', so strlen returns 1 even though the literal holds three characters plus a terminator.

More C Programming questions

Exams that ask this topic