Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uint8 displays weird characters

Tags:

c++

visual-c++

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?

like image 758
aks Avatar asked Sep 04 '10 10:09

aks


1 Answers

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.

like image 85
usta Avatar answered Oct 26 '22 23:10

usta