Using scanf for reading an unsigned char

前端 未结 2 2001
刺人心
刺人心 2020-12-31 00:17

I\'m trying to use this code to read values between 0 to 255 (unsigned char).

#include
int main(void)
{
    unsigned char value;         


        
2条回答
  •  感情败类
    2020-12-31 00:45

    The %u specifier expects an integer which would cause undefined behavior when reading that into a unsigned char. You will need to use the unsigned char specifier %hhu.

提交回复
热议问题