简体   繁体   中英

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. The actual value is 9223372036854775807. How do I get it display so?

printf %d takes an int . This question really is "how do I print a long int with printf ?".

The answer is to use %ld (and %lld for long long int ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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