Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (s) snprintf(3)
NAME
snprintf - Stores formatted output into a character array
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <stdio.h>
int snprintf (
char *string,
size_t n,
const char *format,
[, value]...
);
PARAMETERS
string Points to a character array in which the converted values will be stored.
n Specifies the size of the character array referred to by string.
format Specifies a character string combining literal characters with conversion
specifications.
value Specifies the data to be converted according to the format parameter.
DESCRIPTION
The snprintf( ) function converts, formats, and stores its value parameters, under control of the
format parameter, into consecutive bytes starting at the address specified by the string parameter.
The snprintf( ) function places a null character \0 at the end.
The snprintf( ) function is essentially identical to the sprintf( ) function except for the presence
and effect of the additional argument n.Ifn is zero, no characters are stored and string may be a
null pointer. Otherwise, any generated characters beyond the n-1st are discarded, rather than
being stored, and a null character is appended after the last character that was actually stored.
The format parameter is a character string that contains two types of objects:
Literal characters, which are copied to the output stream.
Conversion specifications, each of which causes zero or more items to be fetched from
the value parameter list.
If there are not enough items for format in the value parameter list, the results are unpredictable.
If more values remain after the entire format has been processed, they are ignored.
Conversion Specifications
Each conversion specification in the format parameter has the following syntax:
A % (percent sign).
The snprintf( ) function can handle a format string that enables the system to process
elements of the parameter list in variable order. In such a case, the normal conversion
character % (percent sign) is replaced by %digit$, where digit is a decimal number in
the range from 1 to NL_ARGMAX. Conversion is then applied to the specified argu-
ment, rather than to the next unused argument. This feature provides for the definition of
527187-017 Hewlett-Packard Company 675