Open System Services Library Calls Reference Manual (G06.27+, H06.04+)

snprintf(3) OSS Library Calls Reference Manual
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 native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
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 Species the size of the character array referred to by string.
format Species a character string combining literal characters with conversion
specications.
value Species 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 specied 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 specications, 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 Specications
Each conversion specication 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 specied argu-
ment, rather than to the next unused argument. This feature provides for the denition of
format strings in an order appropriate to specic languages. When variable ordering is
652 Hewlett-Packard Company 527187-004