如何使用 GCC 在 C99 中打印 long long int
和 unsigned long long int
?
我已经搜索了建议使用 %lld
的其他帖子,但它给出了这些警告:
warning#1: unknown conversion type character 'l' in format [-Wformat]|
warning#2: too many arguments for format [-Wformat-extra-args]|
对于以下尝试:
#include <stdio.h>
int main()
{
long long int x = 0;
unsigned long long int y = 0;
printf("%lld\n", x);
printf("%llu\n", y);
}
最佳答案
如果您在 Windows 上并使用 mingw,则 gcc 使用 win32 运行时,其中 printf 需要 %I64d
作为 64 位整数。 (和 %I64u
用于未签名的 64 位整数)
对于大多数其他平台,您将使用 %lld
来打印 long long。 (和 %llu
如果它是未签名的)。这在 C99 中已标准化。
gcc 没有完整的 C 运行时,它依赖于它运行的平台 - 所以一般情况下你需要查阅你的特定平台的文档 - 独立于 gcc。
关于c - 使用 GCC 在 C 中打印 printf long long int?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13590735/