The sprintf() function is same as the printf() function except that the output is put into the array pointed to by buf instead of being written to the stdout. The array pointed to by buf is null terminated.
#include<stdio.h> int sprintf(char *buf, const char *format, ...);
The return value is equal to the number of characters actually placed into the array.
The sprintf() provides no bound checking on the array pointed to by buf. It means that the array will be overrun if the output generated by sprintf() is greater than the array can hold.
After the following code fragments executes, str holds one 2 3 :
char str; sprintf(str, "%s %d %c", "one", 2, '3');