Table 1

Conversion Specifiers

   In the descriptions that follow, I summarize the match
pattern and conversion rules for each valid conversion
specifier. w stands for the field width you specify, or the
indicated default value if you specify no field width. ptr
stands for the next argument to consume in the varying
length argument list:
   c — stores w characters (default is 1) in the array of
char whose first element is pointed at by ptr. It does not
skip leading whitespace.
   d — converts the integer input field by calling strtol
with a base of 10, then stores the result in the int pointed
at by ptr.
   hd — converts the integer input field by calling strtol
with a base of 10, then stores the result in the short
pointed at by ptr.
   ld — converts the integer input field by calling strtol
with a base of 10, then stores the result in the long
pointed at by ptr.
   e — converts the floating point input field by calling
strtod, then stores the result in the float pointed at by
ptr.
   le — converts the floating point input field by calling
strtod, then stores the result in the double pointed at by
ptr.
   Le — converts the floating point input field by calling
strtod, then stores the result in the long double pointed
at by ptr.
   E — is the same as e.
   lE — is the same as le.
   LE — is the same as Le.
   f — is the same as e.
   lf — is the same as le.
   Lf — is the same as Le.
   g — is the same as e.
   lg — is the same as le.
   Lg — is the same as Le.
   G — is the same as e.
   lG — is the same as le.
   LG — is the same as Le
   i — converts the integer input field by calling strtol
with a base of zero, then stores the result in the int
pointed at by ptr. (A base of zero lets you write input
that begins with 0, 0x, or 0X to specify an actual numeric
base other than 10.)
   hi — converts the integer input field by calling strtol
with a base of zero, then stores the result in the short
pointed at by ptr.
   i — converts the integer input field by calling strtol
with a base of zero, then stores the result in the long
pointed at by ptr.
   n — converts no input, but stores the cumulative
number of matched input characters in the int pointed at
by ptr. It does not skip leading whitespace.
   hn — converts no input, but stores the cumulative
number of matched input characters in the short pointed
at by ptr. It does not skip leading whitespace.
   ln — converts no input, but stores the cumulative
number of matched input characters in the long pointed
at by ptr. It does not skip leading whitespace.
   o — converts the integer input field by calling strtoul
with a base of eight, then stores the result in the
unsigned int pointed at by ptr.
   ho — converts the integer input field by calling
strtoul with a base of eight, then stores the result in the
unsigned short pointed at by ptr.
   lo — converts the integer input field by calling
strtoul with a base of eight, then stores the result in the
unsigned long pointed at by ptr.
   p — converts the pointer input field, then stores the
result in the void * pointed at by ptr. Each
implementation defines its pointer input field to be consistent with
pointers written by the print function.
   s — stores up to w non-whitespace characters (default
is the rest of the input) in the array of char pointed at by
ptr. It first skips leading whitespace, and it always stores a
null character after any input.
   u — converts the integer input field by calling strtoul
with a base of 10, then stores the result in the unsigned
int pointed at by ptr.
   hu — converts the integer input field by calling
strtoul with a base of 10, then stores the result in the
unsigned short pointed at by ptr.
   lu — converts the integer input field by calling
strtoul with a base of 10, then stores the result in the
unsigned long pointed at by ptr.
   x — converts the integer input field by calling strtoul
with a base of 16, then stores the result in the unsigned
int pointed at by ptr.
   hx — converts the integer input field by calling
strtoul with a base of 16, then stores the result in the
unsigned short pointed at by ptr.
   lx — converts the integer input field by calling
strtoul with a base of 16, then stores the result in the
unsigned long pointed at by ptr.
   X — is the same as x.
   hX — is the same as hx.
   lX — is the same as lx.
   % — converts no input, but matches a percent
character. (%)