什么是UL%和%鲁C画幅符之间的区别? [英] What's the difference between %ul and %lu C format specifiers?
问题描述
在的C的Primer Plus为例,笔者使用了%UL
格式说明(在scanf函数和printf)对于无符号长。当我尝试概括的问题,似乎%UL
使得一些错误在我的电脑。但是,使用鲁%
解决了问题。
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 the problem, it seems that the %ul
makes something wrong in my computer. But using %lu
solved the issue.
其实,而非着眼于问题的codeS行了,我想知道的%UL
和的区别鲁%
。也许我可以找出什么是错的。
Actually, rather than focusing on the problem and the line of codes, I want to know about the difference between %ul
and %lu
. Maybe I could figure out what's wrong.
搜索不给我一些有用的东西(除了它们是不同的)。
Searching doesn't give me something useful (except that "they are different").
任何解释或链接/参考AP preciated。
Any explanation or link/reference is appreciated.
推荐答案
%禄
是正确的,而%UL
是的不正确的
一个 的printf
格式说明如下形式%[国旗] [宽度] [precision] [长度]说明
。
U
是说明的意思是无符号的十进制整数。
u
is a specifier meaning "unsigned decimal integer".
→
是长度的修改意为长。
的长度的修改应在转换前的说明的,这意味着%禄
走的是正确的。
The length modifier should go before the conversion specifier, which means %lu
is correct.
这篇关于什么是UL%和%鲁C画幅符之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!