here is another solution using an union. This is better in that more people are probably able to figure out what it does, as opposed to the <?. However, it uses 4 bytes for each char, rather then just 1.
Code:
#include <iostream>
typedef union
{
unsigned char byte;
unsigned int print;
} chars;
void main(void)
{
chars test1;
test1.print = 0; // must initialize all 4 bytes to 0
test1.byte = 255;
cout << test1.print << " " << test1.byte << endl;
}
Matt, I think when Mike said that a char was 4 bytes, he meant that when he cast the char to unsigned int, it printed out a number that could only be represented in 4 bytes, which would make sense becasue of the casting. To consider UTF-8, etc is just too much thinking ;-)