The printf function directs the result of any formatted input string combined with parameters to the screen. There is a companion function (sprintf) that performs the same formatting, but that directs the result to a string (character array). This enables the programmer to perform a variety of pre-formatting tasks.
Possible uses for this include creating record data in memory to be formatted for screen printing and file output within certain parameters at a later stage. It can also be useful in building up a line (or page) for output in one call rather than using multiple calls to printf, which can be quite slow.
The generic form for the sprintf function is as follows:
sprintf ( <output>, <format>, <variables . . .> )
In this definition, ...