← Quiz: C Arrays and Strings: all 10 questions
Quiz: C Arrays and Strings · Question 1 of 10
What does this print? (code)
What does this print?
#include <stdio.h>
#include <string.h>
int main(void) {
char s[] = "hello";
printf("%zu %zu", strlen(s), sizeof(s));
return 0;
}
- A.5 5
- B.5 6
- C.6 6
- D.6 5
Answer & explanation
Correct answer: 5 6
strlen stops before '\0' (5); sizeof includes it (6).
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 →