Convert a binary file to c code
Any file can be converted to c code. For instance, the image will be converted to
static const unsigned char arr[768] = {
0x89,0x50,0x4E,0x47,0x0D,0x0A,0x1A,0x0A,0x00,0x00,0x00,0x0D,0x49,0x48,0x44,0x52,
0x00,0x00,0x00,0x5A,0x00,0x00,0x00,0x5A,0x08,0x06,0x00,0x00,0x00,0x38,0xA8,0x41,
0x02,0x00,0x00,0x02,0xC6,0x49,0x44,0x41,0x54,0x78,0x5E,0x63,0x18,0x05,0xA3,0x21,
0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,
0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,
0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x40,0x6A,0x08,0x30,0x92,0x15,0x64,0xA2,
0x32,0x32,0x0C,0x3A,0x96,0x96,0x43,0x37,0xB8,0xFF,0xFC,0x61,0x38,0xB4,0x69,0x13,
0xC3,0xDF,0xBF,0x7F,0xE9,0xE5,0x07,0x16,0xB2,0x2C,0x02,0x05,0x72,0xD3,0xAA,0x55,
0x43,0x3A,0x5D,0xEF,0x99,0x3A,0x95,0xA1,0x31,0x27,0x87,0x5E,0x7E,0x60,0x1A,0xB1,
0x85,0x80,0x4B,0x76,0x36,0x43,0x6E,0x63,0xE3,0x68,0x40,0xD3,0x23,0x04,0xC2,0xEA,
0xEA,0x18,0xA2,0xF2,0xF2,0xE8,0x61,0x15,0xD3,0x88,0xAF,0xD6,0x32,0xFB,0xFB,0x19,
0x3C,0x02,0x03,0x69,0x1D,0x0E,0x2C,0xB4,0xB4,0xC0,0x82,0x8F,0x81,0x41,0x96,0x6D,
0xE0,0xA3,0xF2,0xF8,0x67,0x06,0x86,0x27,0x3F,0x71,0xB9,0x83,0x89,0x89,0xA1,0x72,
0xD9,0x32,0x86,0x77,0x6E,0x6E,0x0C,0xA7,0x0E,0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,0x1C,0x18,0x6D,0xDE,0x8D,0x36,0xEF,0x46,0x73,0x01,0xE9,0x21,0x30,0xDA,0x8E,
0x66,0x18,0x2D,0x3A,0x86,0x55,0xC6,0x21,0x6F,0x57,0xD6,0xAB,0xC7,0x8F,0x19,0xF6,
0xAF,0x5E,0x3D,0x22,0x8B,0x90,0xAB,0xC7,0x8F,0x8F,0x16,0x9D,0xA3,0x21,0x30,0x1A,
0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,
0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,0x21,0x30,0x1A,0x02,0xA3,
0x21,0x30,0x1A,0x02,0xA3,0x21,0x40,0x97,0x10,0x00,0x00,0x47,0xBD,0x5A,0xD7,0xD9,
0x1A,0xCC,0x02,0x00,0x00,0x00,0x00,0x49,0x45,0x4E,0x44,0xAE,0x42,0x60,0x82,0x82
};
binary2c <input.bin> <output.c>
Just one file to compile. If you want you can build with CMake.