I am doing an C++ exercise and the task is to write a program that
prints all INT values between 32 to 255 and the corresponding ASCII characters.

I have declared the variables to store the ASCII character and the INT like this:

unsigned char unchar;
int i;

And the following statements within a FOR loop will do the print out:

unchar = i; 
cout  << setw(3) << i << " " << unchar << " ";

My question is why g++/LINUX development environment will print
a 'rubbish character`for the INT values between 128 and 255
while Visual C++ 2008 Express Edition run on Windows Vista
will print the characters that are requested in the task specification
with the same source code.
E.g 128 Ç 129 ü and so on.

Windows use code pages as a default. DOS used be 437 but its typically 850. These are full character sets. Linux as far as I know still use 7-bit ASCII not 8-bit!

Then my code is correct and the difference in output depends on the development environment? We are requested to write ANSI compliant code.

This question has already been answered. Start a new discussion instead.