Standard Input for Unsigned Character

前端 未结 2 2077
灰色年华
灰色年华 2021-01-29 14:53

I am trying to send unsigned characters through a program, and I would like to be able to get the numbers through standard input (ie std::cin). For example when I type 2 I woul

2条回答
  •  耶瑟儿~
    2021-01-29 15:15

    When you enter 2 via std::cin, it's correctly interpreted as the character literal '2'.

    You should replace

    unsigned char e = 2;
    

    with

    unsigned char e = '2';
    

提交回复
热议问题