← Quiz: C Arrays and Strings: all 10 questions
Quiz: C Arrays and Strings · Question 8 of 10
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
char s[] = "place\0ment";
printf("%s %zu\n", s, sizeof(s));
return 0;
}
- A.placement 10
- B.place 6
- C.place 11
- D.place 5
Answer & explanation
Correct answer: place 11
printf stops at the first '\0'. The array still holds all 10 characters written plus the final '\0', so sizeof is 11.
Can you get the rest right without peeking?
Take the timed Quiz: C Arrays and Strings quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →