把一个二进制文件转换为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);