COHERENT manpages

This page displays the COHERENT manpage for sprintf() [Format output].

List of available manpages
Index


sprintf() -- STDIO Function (libc)

Format output
#include <stdio.h>
int sprintf(string, format [ , arg ] ...)
char *string, *format;

sprintf() formats and prints a string.  It resembles the function printf(),
except that  it writes its  output into the  memory location pointed  to by
string, instead of to the standard output.

sprintf() reads the string pointed to by format to specify an output format
for each  arg; it then writes  every arg into string, which  it ends with a
null character.  For a detailed discussion of sprintf()'s formatting codes,
see printf().

If it wrote the formatted string correctly, sprintf() returns the number of
characters written.  Otherwise, it returns a negative number.

Example

For an example of this function, see the entry for sscanf().

See Also

printf(),
fprintf(),
libc,
vsprintf()
ANSI Standard, §7.9.6.5
POSIX Standard, §8.1

Notes

The output  string passed  to sprintf()  must be large  enough to  hold all
output characters.

Because  C  does not  perform  type  checking, it  is  essential that  each
argument match its format specification.