/file2header

Convert any binary to a C-style array

Primary LanguageC++

file2header

Convert any binary to a C-style array (generating an header file)

Usage

$ file2header <input_binary.exe> <output_header.h> <bytes_per_line>
<input_binary.exe>    Path to any binary file
<output_header.h>     Path to output file
<bytes_per_line>      Optionnal: Number of bytes for each line (default: 25)
Example: file2header image.exe image.h 30

Output example

#pragma once
#include <cstdint>

const uint8_t image[] = 
{
    0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 
    0xFF, 0xFF, 0x00, 0x00, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 //...
};