Bagikan melalui


Size Specification

The optional prefixes to type, h, l, I, I32, I64, and ll specify the "size" of argument (long or short, 32- or 64-bit, single-byte character or wide character, depending upon the type specifier that they modify). These type-specifier prefixes are used with type characters in printf functions or wprintf functions to specify interpretation of arguments, as shown in the following table. These prefixes are Microsoft extensions and are not ANSI-compatible.

Note

The h and l prefixes are Microsoft extensions when used with data of type char.

Size Prefixes for printf and wprintf Format-Type Specifiers

To specify

Use prefix

With type specifier

long int

l (lowercase L)

d, i, o, x, or X

long unsigned int

l

o, u, x, or X

long long

ll

d, i, o, x, or X

short int

h

d, i, o, x, or X

short unsigned int

h

o, u, x, or X

__int32

I32

d, i, o, x, or X

unsigned __int32

I32

o, u, x, or X

__int64

I64

d, i, o, x, or X

unsigned __int64

I64

o, u, x, or X

ptrdiff_t (that is, __int32 on 32-bit platforms, __int64 on 64-bit platforms)

I

d, i, o, x, or X

size_t (that is, unsigned __int32 on 32-bit platforms, unsigned __int64 on 64-bit platforms)

I

o, u, x, or X

long double

l or L

f

Single-byte character with printf functions

h

c or C

Single-byte character with wprintf functions

h

c or C

Wide character with printf functions

l

c or C

Wide character with wprintf functions

l

c or C

Single-byte – character string with printf functions

h

s or S

Single-byte – character string with wprintf functions

h

s or S

Wide-character string with printf functions

l

s or S

Wide-character string with wprintf functions

l

s or S

Wide character

w

c

Wide-character string

w

s

Thus to print single-byte or wide-characters with printf functions and wprintf functions, use format specifiers as follows.

To print character as

Use function

With format specifier

single byte

printf

c, hc, or hC

single byte

wprintf

C, hc, or hC

wide

wprintf

c, lc, lC, or wc

wide

printf

C, lc, lC, or wc

To print strings with printf functions and wprintf functions, use the prefixes h and l analogously with format type-specifiers s and S.

See Also

Reference

printf, _printf_l, wprintf, _wprintf_l