snprintf

Syntax:

    #include <cstdio>
    int snprintf( char *buffer, int buff_size, const char *format, ... );

The snprintf() function is just like sprintf(), except that the length of the buffer is given. This prevents buffer overflows.

The return value is the number of characters written. If the output was truncated due to buff_size limit then the return value is the number of characters (not including the trailing '\0') which would have been written to the final string if enough space had been available.

Related Topics: sprintf, atof, atoi, atol, fprintf, printf