How do I printf() a uint16_t?

后端 未结 3 1657
天涯浪人
天涯浪人 2021-02-05 06:27

I need to use printf() to print a uint16_t. This SO answer (How to print uint32_t and uint16_t variables value?) says I need to use inttypes.h.

However, I\'m working on

3条回答
  •  一整个雨季
    2021-02-05 06:39

    short int is the smallest at least 16 bits long so convert the value to unsigned short int and print it with %hu.

提交回复
热议问题