*Conan The Librarian
Performs formatted output to a string in memory.
int sprintf (char *str, const char *format_spec, . . . );
The address of the string that will receive the formatted output.
It is assumed that this string is large enough to hold the
A pointer to a character string that contains the format
. . .
Optional expressions whose resultant types correspond to
conversion specifications given in the format specification.
If no conversion specifications are given, you may omit the
output sources. Otherwise, the function calls must have at least
as many output sources as there are conversion specifications,
and the conversion specifications must match the types of the
Conversion specifications are matched to output sources in left-
to-right order. Excess output pointers, if any, are ignored.
A null character is automatically appended to the end of the
output string. Consider the following example of a conversion
int temp = 4, temp2 = 17;
sprintf(s, "The answers are %d, and %d.", temp, temp2);
In this example, character string s has the following contents:
The answers are 4, and 17.
x The number of characters placed in the
output string, not including the final null
Negative value Indicates an output error occurred. The
function sets errno. For a list of errno
values set by this function, see fprintf.