sprintf

Syntax

int sprintf (char * str, const char * format, ... )

Arguments

str
Pointer to a string buffer to store the string
format
Specifies the format of the resulting string, including types of the variables to be included in the string.

Return

The number of bytes printed if successful, otherwise a negative number if unsuccessful.

Description

sprintf "prints" a formatted string, except instead of printing it to a terminal console, it stores the result in a string variable.

Also see

snprintf, formatString

Comments

Wherever possible, you should use snprintf instead. sprintf can have potential buffer overruns (crashes) depending how it is used - snprinf prevents the overruns.