ProgrammingHardTCS NQT · Infosys

char s[] = "hello"; printf("%zu %zu", sizeof s, strlen(s)); prints what?

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

Correct answer: D. 6 5

sizeof counts the terminating null character, giving 6. strlen counts characters before the terminator, giving 5.

More C Programming questions

Exams that ask this topic