VMS Help
CRTL, snprintf
*Conan The Librarian
|
Performs formatted output to a string in memory.
Format
#include <stdio.h>
int snprintf (char *str, size_t n, const char
*format_spec, . . . );
str
The address of the string that will receive the formatted output.
n
The size of the buffer referred to by str.
format_spec
A pointer to a character string that contains the format
specification.
. . .
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
output sources.
Conversion specifications are matched to output sources in left-
to-right order. Excess output pointers, if any, are ignored.
The snprintf function is identical to the sprintf function with
the addition of the n argument, which specifies the size of the
buffer referred to by str.
On successful completion, snprintf returns the number of bytes
(excluding the terminating null byte) that would be written to
str if n is sufficiently large.
If n is 0, nothing is written, the number of bytes (excluding the
terminating null) that would be written if n were sufficiently
large are returned, and str might be a NULL pointer. Otherwise,
output bytes beyond the n - 1st are discarded instead of being
written to the array, and a null byte is written at the end of
the bytes actually written into the array.
If an output error is encountered, a negative value is returned.
x The number of bytes (excluding the terminating
null byte) that would be written to str if n
is sufficiently large.
Negative value Indicates an output error occurred. The
function sets errno. For a list of errno
values set by this function, see fprintf.