It reverses them, but it skips over any whitespace it may encounter (such as byte 20 in ASCII). Also, I don't know how to jump ahead 4 bytes after writing them each time. I am a bit of a C++ n00b so help would be fantastico.[/quote]#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <stddef.h>
int main()
{
ifstream in_stream;
ofstream out_stream;
in_stream.open("infile.dat");
unsigned char byte[4];
in_stream >> byte[0] >> byte[1] >> byte[2] >> byte[3];
out_stream.open("midfile.dat");
out_stream << byte[3] << byte[2] << byte[1] << byte[0];
return 0;
}
Reverse endianizer in C++
Reverse endianizer in C++
Well, my basic plan of attack was to just make an array that read in the data (4 bytes at a time) and wrote it to file backwards (4 bytes at a time). Here is the source code so far:
-
- Posts: 732
- Joined: Wed Nov 26, 2003 11:59 pm
- Location: Raleigh, NC, USA
![]() |
-
- Posts: 21
- Joined: Wed Dec 10, 2003 3:01 am
-
- Posts: 732
- Joined: Wed Nov 26, 2003 11:59 pm
- Location: Raleigh, NC, USA
![]() |