uint8_t can't be printed with cout

前端 未结 8 2277

I have a weird problem about working with integers in C++.

I wrote a simple program that sets a value to a variable and then prints it, but it is not working as expe

8条回答
  •  滥情空心
    2020-11-21 14:03

    It's because the output operator treats the uint8_t like a char (uint8_t is usually just an alias for unsigned char), so it prints the character with the ASCII code (which is the most common character encoding system) 5.

    See e.g. this reference.

提交回复
热议问题