I think this has been around for a while:
$ echo 'test' | xxd -i -n foo unsigned char foo[] = { 0x74, 0x65, 0x73, 0x74, 0x0a }; unsigned int foo_len = 5;