脚本/工具文件转换为C / C ++源代码code数组 [英] script/tool to convert file to C/C++ source code array
问题描述
我需要一个脚本/工具,它读取一个二进制文件,输出C / C ++源代码code数组(重新presents文件内容)。是否有任何?
I need a script/tool which reads a binary file and outputs a C/C++ source code array (which represents the file content). Are there any?
(这个问题前面已经删除了。我把这个问题早在,因为它是有价值的。我正在寻找的正是这种在谷歌,并没有发现任何东西。当然,这是微不足道的code自己,但我会救我是否已经发现了这样一个简单的脚本一些分钟。因此,它是有价值的。
(This question was deleted earlier. I put this question back in because it is valuable. I was searching for exactly this on Google and didn't found anything. Of course it is trivial to code myself but I would have saved some minutes if I would have found such a simple script. Thus it is valuable.
这也问题有很多的向下票没有太多的解释。之前你失望票,为什么你认为这是没有价值的或坏的价值,请发表评论。
This questions also had a lot of down-votes without much explanation. Please comment before you down-vote why you think this is of no value or of bad value.
这个问题也引起了很多困惑什么我问我。如果有什么不清楚,请询问。我真的不知道如何使它更加清晰。看到答案的例子。
This question also caused a lot of confusion about what I am asking about. If something is unclear, please ask. I don't really know how to make it more clear. See the answers for examples.
也(把这里的问题之后),我已经有几个答案。我只想把/他们在这里(再次)联系起来,因为我认为这可能是为别人寻找这非常有用。)
Also (after putting the question here), I already have several answers. I just want to put/link them here (again) because I think it might be useful for someone else searching for this.)
推荐答案
在Debian和其他Linux发行版默认安装(与 VIM
)的 XXD
工具,其中,由于在 -i
选项,可以做你想做的:
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;
这篇关于脚本/工具文件转换为C / C ++源代码code数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!