Standard C++ Library Reference ISO/IEC (VERSION3)
You write %c to generate a single character from the converted value.
printf("%c", 'a') generates a
printf("<%3c|%-3c>", 'a', 'b') generates < a|b >
For a wide stream, conversion of the character x occurs as if by calling btowc(x).
wprintf(L"%c", 'a') generates btowc(a)
You write %lc to generate a single character from the converted value. Conversion of the
character x occurs as if it is followed by a null character in an array of two elements of type
wchar_t converted by the conversion specification ls.
printf("%lc", L'a') generates a
wprintf(L"lc", L'a') generates L'a'
You write %d, %i, %o, %u, %x, or %X to generate a possibly signed integer representation. %d
or %i specifies signed decimal representation, %o unsigned octal, %u unsigned decimal, %x
unsigned hexadecimal using the digits 0-9 and a-f, and %X unsigned hexadecimal using the
digits 0-9 and A-F. The conversion generates at least p digits to represent the converted value.
If p is zero, a converted value of zero generates no digits.
printf("%d %o %x", 31, 31, 31) generates 31 37 1f
printf("%hu", 0xffff) generates 65535
printf("%#X %+d", 31, 31) generates 0X1F +31
You write %e or %E to generate a signed decimal fractional representation with a decimal
power-of-ten exponent. The generated text takes the form ±d.dddE±dd, where ± is either a plus
or minus sign, d is a decimal digit, the decimal point (.) is the decimal point for the current
locale, and E is either e (for %e conversion) or E (for %E conversion). The generated text has
one integer digit, a decimal point if p is nonzero or if you specify the # format flag, p fraction
digits, and at least two exponent digits. The result is rounded. The value zero has a zero
exponent.
printf("%e", 31.4) generates 3.140000e+01
printf("%.2E", 31.4) generates 3.14E+01
You write %f to generate a signed decimal fractional representation with no exponent. The
generated text takes the form ±d.ddd, where ± is either a plus or minus sign, d is a decimal
digit, and the decimal point (.) is the decimal point for the current locale. The generated text has
at least one integer digit, a decimal point if p is nonzero or if you specify the # format flag, and
p fraction digits. The result is rounded.
printf("%f", 31.4) generates 31.400000
printf("%.0f %#.0f", 31.0, 31.0)generates 31 31.
You write %g or %G to generate a signed decimal fractional representation with or without a
decimal power-of-ten exponent, as appropriate. For %g conversion, the generated text takes the
same form as either %e or %f conversion. For %G conversion, it takes the same form as either
%E or %f conversion. The precision p specifies the number of significant digits generated. (If p
is zero, it is changed to 1.) If %e conversion would yield an exponent in the range [-4, p), then