简体   繁体   English

如何打印长数据类型的最大数量?

[英]How to print the maximum number of long data type?

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(){
printf("The maximum number limit of long type is %d.\n",LONG_MAX);
return 0;
}

The code above is okay, but when it is printed. 上面的代码还可以,但是在打印时。 It shows that the max number is 2147483647. The max number limimt for int. 它显示最大数量为2147483647。int的最大数量为limimt。 The actual value is 9223372036854775807. How do I get it display so? 实际值为9223372036854775807。如何显示它?

printf %d takes an int . printf %d需要一个int This question really is "how do I print a long int with printf ?". 这个问题确实是“如何使用printf打印long int ?”。

The answer is to use %ld (and %lld for long long int ). 答案是使用%ld (对于long long int使用%ld %lld )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM