ProgrammingVery hardGATE CS · Campus placements

char s[] = "a\0b"; What is strlen(s)?

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

Correct answer: C. 1

strlen stops at the first null byte, which here is the embedded one after a. The array holds four bytes in total, but the string length is 1.

More C Programming questions

Exams that ask this topic