Share via


Size and Distance Specification

The optional prefixes to type, h, l, and L, specify the “size” of argument (long or short, 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.

Table R.6   Size Prefixes for printf and wprintf Format-Type Specifiers

To Specify Use Prefix With Type Specifier
long int l d, i, o, x, or X
long unsigned int l u
short int h d, i, o, x, or X
short unsigned int h u
__int64 I64 d, i, o, u, x, or X
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

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, or lC
wide printf C, lc, or lC

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