On Debian and other Linux distros is installed by default (along with vim
) the xxd
tool, which, given the -i
option, can do what you want:
matteo@teodeb:~/Desktop$ echo Hello World\! > temp
matteo@teodeb:~/Desktop$ xxd -i temp
unsigned char temp[] = {
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21,
0x0a
};
unsigned int temp_len = 13;