HP C/iX Library Reference Manual (30026-90004)

Chapter 5 277
HP C/iX Library Function Descriptions
printmsg
printmsg
Prints formatted output with numbered arguments to stdout.
Syntax
#include <stdio.h>
int printmsg (
format [
,
arg]
...)
char *
format
;
Parameters
format
A pointer to the string containing the formatting information. It contains
optional placeholders and formatting specifications where
arg1
through
argn
are to be substituted.
arg1 ... argn
A character, character pointer or integer value giving the parameter to
be converted, formatted, and merged with
format
prior to output.
Return Values
x The number of characters transmitted.
EOF An error occurred.
Description
The printmsg function places output on the standard output stream stdout after
performing parameter substitution.
The printmsg function is derived from printf().Inprintmsg(), the conversion character
% is replaced by the sequence %n$. n is a decimal digit in the range 1-9, and indicates that
this conversion should be applied to the nth argument, rather than to the next unused one.
All other aspects of formatting are unchanged. All conversion specifications must contain
the %n$ sequence, and you should make sure the numbering is correct. All parameters
must be used exactly once.
See printf() for more details on formatting and conversion specifications.
Example
The following creates a date and time printing function:
printmsg(
format, weekday, month, day, hour, min
);
The format is a pointer to the following string:
"%1$s, %2$s %3$d, %4$d:%5$.2d\n"
The resulting output is:
Sunday, July 3, 10:02