Standard C++ Library Reference ISO/IEC (VERSION3)

%f conversion occurs instead. The generated text has no trailing zeros in any fraction and has a
decimal point only if there are nonzero fraction digits, unless you specify the # format flag.
printf("%.6g", 31.4) generates 31.4
printf("%.1g", 31.4) generates 3.14e+01
You write %n to store the number of characters generated (up to this point in the format) in an
integer object whose address is the value of the next successive argument.
printf("abc%n", &x) stores 3
You write %p to generate an external representation of a pointer to void. The conversion is
implementation defined.
printf("%p", (void *)&x) generates, e.g. F4C0
You write %s to generate a sequence of characters from the values stored in the argument C
string.
printf("%s", "hello") generates hello
printf("%.2s", "hello") generates he
For a wide stream, conversion occurs as if by repeatedly calling mbrtowc, beginning in the
initial conversion state. The conversion generates no more than p characters, up to but not
including the terminating null character.
wprintf(L"%s", "hello") generates hello
You write %ls to generate a sequence of characters from the values stored in the argument
wide-character string. For a byte stream, conversion occurs as if by repeatedly calling
wcrtomb, beginning in the initial conversion state, so long as complete multibyte characters
can be generated. The conversion generates no more than p characters, up to but not including
the terminating null character.
printf("%ls", L"hello") generates hello
wprintf(L"%.2s", L"hello") generates he
You write %% to generate the percent character (%).
printf("%%") generates %
See also the Table of Contents and the Index.
Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.