snprintf() in C library
The snprintf() function formats and stores a series of characters and values in the array buffer. The snprintf() function with the addition of the n argument, which indicates the maximum number of characters (including at the end of null character) to be written to buffer. It is defined in <stdio.h> header file.
The snprintf() function is used to redirect the output of printf() function onto a buffer.
The snprintf() also returns the number characters written onto the buffer, similar to the printf statement, which returns the number of characters that is printed in stdout.
int snprintf(char *str, size_t size, const char *format, ...); *str : is a buffer. size : is the maximum number of bytes (characters) that will be written to the buffer. format : C string that contains a format string that follows the same specifications as format in printf ... : the optional ( …) arguments are just the string formats like (“%d”, myint) as seen in printf.
string: geeks character count = 14