Hi,
I've declared a uint8 variable and when the value in it is printed, I get smiley faces and white spaces. Shouldn't it display integer values?
Hi,
I've declared a uint8 variable and when the value in it is printed, I get smiley faces and white spaces. Shouldn't it display integer values?
I bet uint8 is a typedef for unsigned char in your system headers. Then std::cout << u
will print symbols rather than integer values, where u is of type uint8.
Try
std::cout << static_cast< int >( u );
or
std::cout << +u;
to have numeric values printed.
It all depends on how you printing the value out. For cout, try cout << (long unsigned int)var;
, and for printf
, you can try using the %lu
format specifier. However, like usta mentioned, uint8
is likely defined or typedef'd as something else, since that is not an ISO C++ type. There is also the possibility that uint8
is typedef'd to unsigned long int
(generic), or unsigned __int64
(MS platform specific), and the MSVC++ compiler is just doing the wrong implicit conversion. Without knowing what uint8
is defined as, it is hard to tell.