代码点读机 / C / long

long C · 关键字

声明长整型变量;它保证至少和 int 一样宽,但具体大小由实现决定。

怎么用

long 变量名 = 值; 或 long long 变量名 = 值;

小例子

#include <stdio.h>
int main(void) {
    long big = 1234567890L;
    printf("%ld", big);
    return 0;
}

运行结果

输出 1234567890

提醒:需要确定大小时用 int32_t/int64_t;大数后加 L 或 LL

官方文档:https://en.cppreference.com/w/c/language/arithmetic_types

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C全部词条