I need to include the contents of a binary file in my C/C++ source code as the text for the declaration of an array initialized to the content of the file. I’m not looking to read the file dynamically at runtime. I want to perform the operation once and then use the generated array declaration text.
How can I convert a binary file to the text for the C/C++ declaration of an array which is initialized to the contents of the file?
On Debian and other Linux distros is installed by default (along with
vim) thexxdtool, which, given the-ioption, can do what you want: