c语言 转换成二进制 数组,二进制文件转化成数组

该博客介绍了一个C语言程序,用于将二进制文件转换为C语言数组,并将该数组保存到新的头文件中。程序包括获取文件大小、读取源文件、创建目标文件的功能,方便在代码中直接使用二进制数据。
摘要由CSDN通过智能技术生成

把一个二进制文件转换为c语言数组:

#include "stdafx.h"

#include

#include

#include

#include

#include

#include "string.h"

unsigned int GetFileSize(char *filename);

void read_src(char *path, unsigned char *buf, unsigned int size);

void make_dstfile(char *outpath, unsigned char *buf, unsigned int size);

int main()

{

unsigned char *buf = NULL;

unsigned int size;

char srcbmp[100]={0};

char dstfile[100]={0};

//char srcbmp[100]="test.bin";

//char dstfile[100]="test.h";

printf("Please input src file name\nC file path name\n");

scanf("%s %s",srcbmp,dstfile);

size = GetFileSize(srcbmp);

buf = (unsigned char *)malloc(sizeof(unsigned char)*size);

read_src(srcbmp, buf, size);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值