Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)

Guardian Native C Library Calls (s) sprintf(3)
NAME
sprintf - 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 sprintf (
char *string,
const char *format
[, value]...
);
PARAMETERS
string Points to a character array in which the converted values will be stored.
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 sprintf( ) 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 sprintf( ) function places a null character \0 at the end. You must ensure that enough storage
space is available to contain the formatted string.
In the TNS environment, the sprintf() function supports only the C/POSIX locale. Thus, any
conversion specications that are locale-dependent do not function correctly in locales other than
the C/POSIX locale. In the native environment, the sprintf() function supports all locales.
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 sprintf( ) function can handle a format string that enables the system to process ele-
ments of the parameter list in variable order. In such a case, the normal conversion char-
acter % (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 argument,
rather than to the next unused argument. This feature provides for the denition of for-
mat strings in an order appropriate to specic languages. When variable ordering is
used, the * (asterisk) specication for eld width in precision is replaced by %digit$.If
the variable ordering feature is used, it must be specied for all conversions.
527192-007 Hewlett-Packard Company 633