繁体   English   中英

如何在gcc中打印UINT64_t?

[英]How to print UINT64_t in gcc?

为什么此代码不起作用?

#include <stdio.h>
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 <inttypes.h>
#include <stdint.h>
#include <stdio.h>

int main()
{
    uint64_t ram = 90;
    printf("%" PRIu64 "\n", ram);
}

您忘记了一些标题, uint64_t ,并且不能将%duint64_t

加:

#include <inttypes.h>

并使用PRIu64(像这样在引号之外):

printf("%"PRIu64"\n", ram);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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