snprintf
snprintf is a function in the C standard library that formats a sequence of characters and stores them in the character array pointed to by str. It is designed to prevent buffer overflows by enforcing a maximum number of characters to write, as specified by the size parameter. The function follows the printf formatting rules and formats the provided arguments according to the format string.
It writes at most size-1 characters from the formatted output and always terminates the destination with a
Special case: if size is 0, nothing is written, but snprintf still returns the length of the
snprintf is defined in the C99 standard and is widely implemented across platforms, including GNU C Library,