This question already has an answer here:
- uint8_t can't be printed with cout 8 answers
If I run this code:
std::cout << static_cast<uint8_t>(65);
It will output:
A
Which is the ASCII equivalent of the number 65. This is because uint8_t
is simply defined as:
typedef unsigned char uint8_t;
Is this behavior a standard? I can not understand that if I want to print the value of a uint8_t
variable, it will be printed as a character. Should not be a better way to define uint8_t
that guaranteed to be dealt with as a number not a character.
P.S. I am using MSVS 2013.
Aucun commentaire:
Enregistrer un commentaire