Which program creates a C array given any file? Which program creates a C array given any file? unix unix

Which program creates a C array given any file?


For large files, converting to text and then making the compiler parse it all over again is inefficient and unnecessary. Use objcopy instead:

objcopy -I binary -O elf32-i386 stuff stuff.o

(Adjust the output architecture as necessary for non-x86 platforms.) Then once you link it into your program, you can access it like so:

extern char _binary_stuff_start[], _binary_stuff_end[];#define SIZE_OF_STUFF (_binary_stuff_end - _binary_stuff_start)...foo(_binary_stuff_start[i]);


hexdump -v -e '16/1 "0x%x," "\n"'

would generate a C like array from stdin, but there is no declaration, no braces or good formatting.