c语言如何编辑二进制文件,C语言在二进制文件中添加,程序该怎么改

2023-05-16

void changecellname();

int main(int argc, char *argv[])

{

if( argc < 3 )

{

printf("usage: %s %s/n", argv[0], "infile outfile");

exit(1);

}

FILE *outfile, *infile;

outfile = fopen(argv[2], "wb" );

infile = fopen(argv[1], "rb");

unsigned char buf[MAXLEN];

unsigned char buf1[MAXLEN];

if( outfile == NULL || infile == NULL )

{

printf("%s, %s",argv[1],"not exit/n");

exit(1);

}

int rc;

while( (rc = fread(buf,sizeof(unsigned char), MAXLEN,infile)) != 0 )

{

changecellname(buf, buf1, rc);

fwrite(buf1, sizeof( unsigned char ), rc, outfile );

}

fclose(infile);

fclose(outfile);

return 0;

}

void changecellname(unsigned char temp1[], unsigned char temp2[], int ltn)

{int i;

i=0;

for (i=0; i

for (i=0; i

{ if( temp1[i] == temp1[0] && temp1[i+1] == temp1[0]+12 && temp1[i+2] == temp1[0]+2 && temp1[i+3] == temp1[0]+6)

{

temp2[i+4] = temp1[0]+54;

temp2[i+5] = temp1[0]+54;

temp2[i+6] = temp1[0]+54;

temp2[i+7] = temp1[0]+54;

}

temp2[0] = temp1[0];

}

}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

c语言如何编辑二进制文件,C语言在二进制文件中添加,程序该怎么改 的相关文章

随机推荐