Cat, I played around with this, and am stumped. I took out the shift left 4, and when I run the following code, I get the same result as keithmolo. I wonder why?
Code:
ifstream fIn2(filename1, ios::binary);
if (!fIn2.is_open())
{
cout << "File not found: " << filename1 << endl;
return 1;
}
ofstream fout(filename2, ios::binary);
if (!fout.is_open())
{
cout << "File could not be opened: " << filename2 << endl;
return 1;
}
char xCha, xChb;
unsigned int combine, shift;
while (fIn2.get(xCha))
{
fIn2.get(xChb);
(unsigned int)combine = ((unsigned int)xCha<<8)|(unsigned int) xChb;
shift = combine;
xCha = (shift >> 8);
xChb = (shift & 0xFF);
fout.put(xChb);
fout.put(xCha);
}
fIn2.close();
fout.close();
in.open(filename2, ios::binary);
cout << endl;
char c;
while (in.get(c))
{
cout << hex << (int) c << endl;
}
in.close();