你怎么printf的一个unsigned long long int类型(格式说明符无符号长长整型)? [英] How do you printf an unsigned long long int(the format specifier for unsigned long long int)?
本文介绍了你怎么printf的一个unsigned long long int类型(格式说明符无符号长长整型)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdio.h>
int main() {
unsigned long long int num = 285212672; //FYI: fits in 29 bits
int normalInt = 5;
printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\n", sizeof(num), num, normalInt);
return 0;
}
输出:
My number is 8 bytes wide and its value is 285212672l. A normal number is 0.
我想这意想不到的结果是从印刷无符号长long int类型
。你怎么的printf()
的无符号长long int类型
?
推荐答案
使用的LL(EL-EL)长隆改性剂与U(无符号)转换。 (工作在Windows中,GNU)。
Use the ll (el-el) long-long modifier with the u (unsigned) conversion. (Works in windows, GNU).
printf("%llu", 285212672);
这篇关于你怎么printf的一个unsigned long long int类型(格式说明符无符号长长整型)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文