C++ Programming/Code/Standard C Library/Functions/sprintf

sprintf
The sprintf function is just like printf, except that the output is sent to buffer. The return value is the number of characters written. For example:

Note that sprintf does the opposite of a function like atoi -- where atoi converts a string into a number, sprintf can be used to convert a number into a string.

For example, the following code uses sprintf to convert an integer into a string of characters:

This code is similar, except that it converts a floating-point number into an array of characters:


 * Related topics: fprintf - printf (Standard C String and Character) atof - atoi - atol