nl_printf(3int)
NAME
nl_printf, nl_fprintf, nl_sprintf − print formatted output
SYNTAX
int nl_printf (format [ , arg ] ... )
char *format;
int nl_fprintf (stream, format [ , arg ] ... )
FILE *stream;
char *format;
int nl_sprintf (s, format [ , arg ] ... )
char *s, *format;
DESCRIPTION
The internationalization functions nl_printf, nl_fprintf, and nl_sprintf provide similar functionality to printf, except the conversion character % in printf is replaced by the sequence %digit$ , where digit is a decimal digit n from 1 to 9. Conversions are applied to the n th argument in the argument list, rather than to the next unused argument.
The format passed to the printing functions contains either a form conversion specification such as % or %digit$ . The two forms cannot be mixed within a single format string.
All the routines allow the insertion of a language-dependent radix character in the output string. The radix character inserted is that defined for the language identified by the last successful call to setlocale category LC_NUMERIC. If setlocale category LC_NUMERIC has not been called successfully, or if the radix character is not defined, the radix character defaults to a period (.).
The conversion specification is the same as the printf function except it can be introduced by either the sequence %digit$ or the % character.
A field width or precision can be indicated by an asterisk (*) instead of a digit string in format strings containing the % form of a conversion specification. In this case, an integer arg supplies the field width or precision. In format strings containing the %digit$ form of a conversion specification, field width or precision can be indicated by the sequence *digit$. The position in the argument list of an integer arg containing the field width or precision is given by digit. This is a decimal digit from 1 to 9. For example:
nl_printf ("%1$d:%2$.*3$d:%4$.*3$d\n",
hour, min, precision, sec);
The format passed to the NLS printing functions can contain either numbered argument specifications (for example, %digit$ and *digit$), or unnumbered argument specifications (for example, % and * ), but not both. The results of mixing numbered and unnumbered argument specifications in a format string are undefined.
The flag characters and their meanings are identical to printf.
The conversion characters and their meanings are identical to printf.
Each digit argument must be used at least once. The results of not using an argument are undefined.
EXAMPLES
To print the language independent date and time format using the following nl_printf statement:
nl_printf (format, weekday, month, day, hour, min);
For American usage, format could be a pointer to the string:
"%1$s, %2$s %3$d, %4$d:%5$.2d\n"
producing the message:
Sunday, July 3, 10:02
whereas for German usage, format could be a pointer to the string:
"%1$s, %3$d. %2$s, %4$d:%5$.2d\n"
producing the message:
Sonntag, 3. Juli, 10:02
SEE ALSO
nl_scanf(3int), setlocale(3int), printf(3s), putc(3s), scanf(3s), stdio(3s)
Subroutines