ProgrammingModerateCognizant GenC · C

What is printed?

What is printed?
char s[] = "hello";
s[2] = '\0';
printf("%zu %zu %s", sizeof s, strlen(s), s + 3);
  1. A. 6 2 lo
  2. B. 6 5 lo
  3. C. 5 2 lo
  4. D. 6 2 llo

Correct answer: A. 6 2 lo

sizeof counts the whole array (6 bytes including the original terminator); strlen stops at the new '\0' (2); s + 3 still points at "lo".

More C Programming questions

Exams that ask this topic