如何给printf"无符号长"用C? [英] How to printf "unsigned long" in C?
本文介绍了如何给printf"无符号长"用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我永远无法理解如何打印用C 无符号长
的数据类型。
假设 unsigned_boo
是无符号长
,然后我尝试:
-
的printf(%lu个\\ N,unsigned_boo)
-
的printf(%杜\\ n,unsigned_boo)
-
的printf(%UD \\ n,unsigned_boo)
-
的printf(%LL \\ n,unsigned_boo)
-
的printf(%LD \\ N,unsigned_boo)
-
的printf(%DL \\ n,unsigned_boo)
和所有的人都打印某种 -123123123
数字代替无符号长
,我有。的p>
解决方案
%禄
是格式正确无符号长
。听起来有在起作用等问题在这里,如内存损坏或者未初始化的变量。也许我们展示一个较大的画面?
I can never understand how to print unsigned long
datatype in C.
Suppose unsigned_boo
is an unsigned long
, then I try:
printf("%lu\n", unsigned_boo)
printf("%du\n", unsigned_boo)
printf("%ud\n", unsigned_boo)
printf("%ll\n", unsigned_boo)
printf("%ld\n", unsigned_boo)
printf("%dl\n", unsigned_boo)
And all of them print some kind of -123123123
number instead of unsigned long
that I have.
解决方案
%lu
is the correct format for unsigned long
. Sounds like there are other issues at play here, such as memory corruption or an uninitialized variable. Perhaps show us a larger picture?
这篇关于如何给printf"无符号长"用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文