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

Ava*_*rri 2 c

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

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

也签了。

pmg*_*pmg 7

包含<inttypes.h>并使用其中的宏

#include <inttypes.h> // <inttypes.h> also includes <stdint.h> on its own
uint_fast8_t a = 0;
uint_fast16_t b = 0
uint_fast32_t c = 0;
uint_fast64_t d = 0;

printf("%" PRIuFAST8 " %" PRIuFAST16 " %" PRIuFAST32 " %" PRIuFAST64 "\n", a, b, c, d);
Run Code Online (Sandbox Code Playgroud)

  • 是的,我在帖子中将“&lt;inttypes.h&gt;”设置为可点击:) (2认同)