sprintf formats output into a character array using the formatting capabilities of printf and fprintf. It places a 0 character at the end and returns the number of characters written before it. section 14.1
Appending formatted numbers
A loop can maintain a pointer to the next buffer position, call sprintf(p, form, nums[i]), and advance p by the returned length before copying a separator. This assumes the destination buffer is large enough. section 14.1
The important safety distinction is:
- sprintf makes no provision against buffer overflow when the destination is too small. section 14.1
- snprintf accepts a byte limit, truncates when necessary, and can report the length that would have been written with a zero-size destination. section 14.1

