Question 11
Back to Exercise
snprintf(buf, 8, "%s", "programming") – what does it return?
- A 7, the characters written
- B 11, the length the full output needed Correct
- C -1, because it did not fit
- D 8, the buffer size
Correct Answer: Option B
buf gets "program" (7 characters + '\0'), and the return value is the untruncated length, 11. A result ≥ the size means the output was cut.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!