The snprintf function is identical to the sprintf function with the addition of the n argument, which specifies the size of the buffer referred to by str. On successful completion, snprintf returns the number of bytes (excluding the terminating null byte) that would be written to str if n is sufficiently large. If n is 0, nothing is written, the number of bytes (excluding the terminating null) that would be written if n were sufficiently large are returned, and str might be a NULL pointer. Otherwise, output bytes beyond the n - 1st are discarded instead of being written to the array, and a null byte is written at the end of the bytes actually written into the array. If an output error is encountered, a negative value is returned.