What's the difference between %ul and %lu C format specifiers?

后端 未结 1 1533
野的像风
野的像风 2021-02-02 00:22

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

相关标签:
1条回答
  • 2021-02-02 01:09

    %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.

    0 讨论(0)
提交回复
热议问题