Writing and reading 0-255 in C++

Hi guys. What can I use to write and read, in order to deal with the full character set 0-255? I include the program that will prove that it doesn’t work. This is the best write and read I could find. I’m using Visual C++ Thank you.

unsigned char Ch1;
int ix, iNumOut;
const string TEST_FILE = “T1.DAT”;

// Write
ofstream testout(TEST_FILE, ios::binary);
for (ix = 0; ix <= 255; ix++)
testout << char(ix);

// Read
ifstream testin(TEST_FILE, ios::binary);
for (ix = 0; ix <= 255; ix++)
testin >> Ch1;
iNumOut = Ch1;
cout << iNumOut << ", ";

What’s your goal here?

I’m creating an encryption program that often writes and read the characters 0-255. Basically I need full control of the 256 numbering system. I did it before in Turbo Pascal and would like to do it again in C++

Thanks guys, I have already found my solution.