#include <stdio.h>
#define FILENAME "test.bin"
int main(void)
{
int tTempFile;
long filelen,ret;
unsigned char *str;
unsigned char tt;
int i;
if((tTempFile=open(FILENAME,O_RDONLY))<0 )
{
printf("Open File %s Failed ! \n",FILENAME);
return -1;
}
filelen=lseek(tTempFile,0,SEEK_END);
lseek(tTempFile,0,SEEK_SET);
str=(unsigned char *)malloc(filelen);
ret=read(tTempFile,str,filelen);
close(tTempFile);
if(ret != filelen)
{
printf("Read Error , Length is Diff ... \n");
return -2;
}
tt=0;
for(i=0;i<filelen;++i)
{
tt+=str[i];
}
printf("tt == %x \n",tt);
return 0;
}
Linux下对某二进制文件进行累加
最新推荐文章于 2023-05-29 17:06:34 发布