ProgrammingHard

char b[4]; int r = snprintf(b, 4, "%d", 123456); printf("%d %s", r, b); What is printed?

  1. A. 6 123
  2. B. 3 123
  3. C. 6 1234
  4. D. 4 123

Correct answer: A. 6 123

The return value is the length the full output would need, 6, even though only '123' and the terminator fit in the 4-byte buffer.

More C Programming questions

Exams that ask this topic