C中的64位整型

__int64 是有符号 64 位整数数据类型,也就是 C# 中的 long 和 SQL Server 中的 bigint,范围为 -2^63 (-9,223,372,036,854,775,808) 到 2^63-1 (9,223,372,036,854,775,807),存储空间占 8 字节。用于整数值可能超过 int 数据类型支持范围的情况。
__int64是Microsoft自创的。要用 64 位整型的话,C 中本来就有自带long long,如下:

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

int main(void)
{
    long long llNum = LLONG_MAX;
    unsigned long long ullNum = ULLONG_MAX;
    printf("%lld\n%llu", llNum, ullNum);

    return EXIT_SUCCESS;
}

参考资料:ANSI C99

Microsoft Windows 下的 VC、BCB、MinGW GCC 等使用__int64,如下:

__int64 n;

scanf("%I64u", &n);
printf("%I64u\n", n);

其中MinGW GCC 还支持用 long long 声明,但输入输出的格式串仍用 I64 开头。
__int64 关键字和 %I64 标号确实是 Microsoft 专有的。标准 C 用 long long 和 %lld。所以在 Unix、Linux、Cygwin 下编程就应该用标准的用法。

原文地址:https://www.cnblogs.com/wxxweb/p/2066500.html