← Quiz: String Handling in C: all 15 questions
Quiz: String Handling in C · Question 13 of 15
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
char b[6];
int n = snprintf(b, sizeof b, "%s", "placement");
printf("%s %d\n", b, n);
return 0;
}
- A.placement 9
- B.place 5
- C.place 9
- D.placem 6
Answer & explanation
Correct answer: place 9
snprintf writes at most 5 characters plus '\0' into the 6-byte buffer, but returns the full length it wanted to write (9).
Can you get the rest right without peeking?
Take the timed Quiz: String Handling in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →