如何在gcc中打印UINT64_t?
为什么这段代码不起作用?
#include main() { UINT64_t ram = 90; printf("%d""\n", ram); }
我收到以下错误:
In function \u2018main\u2019 error: \u2018UINT64_t\u2019 undeclared (first use in this function) error: (Each undeclared identifier is reported only once error: for each function it appears in.) error: expected \u2018;\u2019 before \u2018ram\u2019
uint64_t
在标准整数类型头文件中定义。 即, stdint.h
。 首先在程序中包含stdint.h
。
然后你可以使用格式说明符"%"PRIu64
打印你的值:即
printf("%" PRIu64 "\n", ram);
您也可以参考这个问题如何在C中打印int64_t类型
完整的工作示例: http : //ideone.com/ttjEOB
#include #include #include int main() { uint64_t ram = 90; printf("%" PRIu64 "\n", ram); }
你忘记了一些标题, uint64_t
并且不能将%d
与uint64_t
加:
#include
并使用PRIu64(在引号之外):
printf("%"PRIu64"\n", ram);