On all systems with 8-bit bytes, they are variants of char
. This includes the type-aliases for e.g. uint8_t
(which is a type-alias for unsigned char
on such a system).
And no matter what type-alias you have, char
(and unsigned char
and signed char
(yes those are three distinctive types)) will be treated as characters by the stream output operator <<
.
If you want to print the integer value of any char
based type you need to cast it to e.g. int
. As in
std::cout << static_cast<unsigned>(my_uint8_t_var) << '\n';
As a side-note: There are systems which doesn't have 8-bit bytes. On such systems type-aliases like uint8_t
are not possible, and does not exist. If you see e.g. this fixed-width integer reference you will see that the exact fixed-width integer types are optional.