1

Consider the following:

int main() {
    unsigned char val(-1); 
    printf( "val = %u\n", val );
    return 0;
}

Ouptut:

val = 255

However when I try to use iostream

int main() {
    unsigned char val(-1);
    std::cout << "val = " << val << std::endl;
}

Output:

val = 

Yet in the debugger when I check val it has the value 255 with the y with double dots above the y.

How can I get iostream to print out the same as printf() with the value of 255

Francis Cugler
  • 7,788
  • 2
  • 28
  • 59

0 Answers0