Ok so I am fairly new to C++ and I came across a program the can take an exe or a bin file and put it in to a .h file for use with C++. The problem I am having is how can I write the raw data that bin2c genarats to a file and then reproduce that same exe. You can find the code below of the raw data. (Using cygwin to compile.) I was not on a PC so I was not able to use the code tags for showing the code sorry.
const unsigned char raw_data[] = {
0x21, 0x20, 0xc2, 0xa6, 0xc3, 0xb4, 0xc2, 0xbf,
0xc3, 0x82, 0xc3, 0x8b, 0xc2, 0xa4, 0x20, 0xc3,
0x8d, 0xc3, 0x8c, 0x4c, 0x3f, 0x20, 0x20, 0xc3,
0x80, 0xc3, 0xbf, 0x20, 0x20, 0xc3, 0x80, 0xc3,
0xbf, 0xc2, 0xa5, 0x20, 0xc5, 0xa1, 0xe2, 0x84,
0xa2, 0xc2, 0xa9, 0x40, 0x20, 0x20, 0xc3, 0x80,
0xc3, 0xbf, 0x20, 0x20, 0xc3, 0x80, 0xc3, 0xbf,
0x60, 0x20, 0x6f, 0x72, 0x20, 0x60, 0x21, 0x20,
0x48, 0xc2, 0xb7, 0xc3, 0xb4, 0xc2, 0xbf, 0xc3,
0x82, 0xc3, 0x8b, 0xc2, 0xa4, 0x20, 0xc3, 0x8d,
0xc3, 0x8c, 0x4c, 0x3f, 0x20, 0x20, 0xc3, 0x80,
0xc3, 0xbf, 0x33, 0x33, 0x33, 0x3f, 0xc2, 0xa5,
0x20, 0xc5, 0xa1, 0xe2, 0x84, 0xa2, 0xc2, 0xa9,
0x40, 0x20, 0x20, 0xc3, 0x80, 0xc3, 0xbf, 0x66,
0x66, 0xc2, 0xa6, 0x40, 0x0a,
};
Use the standard C++ I/O gymnastics:
You can just declare the array as a
const chararray and do away with the cast, if you prefer.