博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux tool: convert binary file to C/C++ source code array
阅读量:2152 次
发布时间:2019-04-30

本文共 804 字,大约阅读时间需要 2 分钟。

FROM:

In case you are programming under Linux and have a binary file that want “import” inside your C/C++ code is there an useful linux utility tool called xxd able to make such conversion in a very easy way. This tool is usually installed by default in all major linux distributions.

The use is very simple, if you have a binary file called, for example, MyFile.bin with length of 100 bytes and wan to convert in a C/C++ source code array you can simply type:

xxd -i MyFile.bin > MyFile.h

The source code array generated inside the header file will have a format like the following:

unsigned char MyFile[] = {  0xXX, 0xXX, ....., 0xXX};unsigned int MyFile_len = 100;

Obviously 0xXX is the hexadecimal content of the binary file. Now you can import the header file just generated and use in your project.

转载地址:http://zciwb.baihongyu.com/

你可能感兴趣的文章
云原生 第十一章 应用健康
查看>>
Leetcode C++ 《第202场周赛》
查看>>
云原生 第十二章 可观测性:监控与日志
查看>>
Leetcode C++ 《第203场周赛》
查看>>
云原生 第十三章 Kubernetes网络概念及策略控制
查看>>
《redis设计与实现》 第一部分:数据结构与对象 || 读书笔记
查看>>
《redis设计与实现》 第二部分(第9-11章):单机数据库的实现
查看>>
算法工程师 面经2019年5月
查看>>
搜索架构师 一面面经2019年6月
查看>>
稻草人手记
查看>>
第一次kaggle比赛 回顾篇
查看>>
leetcode 50. Pow(x, n)
查看>>
leetcode 130. Surrounded Regions
查看>>
【托业】【全真题库】TEST2-语法题
查看>>
博客文格式优化
查看>>
【托业】【新托业全真模拟】疑难语法题知识点总结(01~05)
查看>>
【SQL】group by 和order by 的区别。
查看>>
【Python】详解Python多线程Selenium跨浏览器测试
查看>>
Jmeter之参数化
查看>>
Shell 和Python的区别。
查看>>