Reading small int with scanf

后端 未结 1 2002
陌清茗
陌清茗 2021-01-23 09:57

Is there a way to read a small int (i.e. 1-byte int of range -128..127) using scanf? Consider this code:

char x;
scanf(\"%d\", &x);
相关标签:
1条回答
  • 2021-01-23 10:34

    scanf needs "%hhd" format string to read into a char.

    0 讨论(0)
提交回复
热议问题