相关疑难解决方法(0)

uint32_t和size_t的printf格式说明符

我有以下内容

size_t   i = 0;
uint32_t k = 0;

printf("i [ %lu ] k [ %u ]\n", i, k);
Run Code Online (Sandbox Code Playgroud)

编译时我收到以下警告:

format ‘%lu’ expects type ‘long unsigned int’, but argument has type ‘uint32_t’
Run Code Online (Sandbox Code Playgroud)

当我使用夹板运行时,我得到以下内容:

Format argument 1 to printf (%u) expects unsigned int gets size_t: k
Run Code Online (Sandbox Code Playgroud)

非常感谢任何建议,

c printf

96
推荐指数
4
解决办法
19万
查看次数

什么是打印 int_fast_32_t 等数据类型的可移植和正确方法

我一直在阅读这篇文章,并且怀疑打印此数据类型的正确且可移植的方法是什么?

uint_fast8_t
uint_fast16_t
uint_fast32_t
uint_fast64_t    
Run Code Online (Sandbox Code Playgroud)

也签了。

c

2
推荐指数
1
解决办法
168
查看次数

标签 统计

c ×2

printf ×1