In an example of \"C Primer Plus\", the author has used %ul
format specifier (in both scanf and printf) for unsigned long. When I try to generalize
%lu
is correct, while %ul
is incorrect.
A printf format specifier follows the form %[flags][width][.precision][length]specifier
.
u
is a specifier meaning "unsigned decimal integer".
l
is a length modifier meaning "long".
The length modifier should go before the conversion specifier, which means %lu
is correct.