本帖最后由 千里同风 于 2013-12-10 14:51 编辑
如下这段代码通不过,但又不知错在哪里,望达人帮助修正一下,万分感谢!
#include "stdio.h"
#include "conio.h"
main()
{
char file [8];
char i,ch,chh,tl,time;
char bc[9]={0x21,0x21,0x47,0x46,0x45,0x44,0x43,0x42,0x41};
FILE * fp;
printf("\n\t Please input a filename:");
scanf("%s",file);
if(fGetc(fp)!=7 &&fGetc(fp)!=7)
{
printf ("\7\nThe file is 000000!") ;
exit(0) ;
}
fseek(fp,7L,0);
fseek(fp, 34L,0);
ch=fGetc(fp);
time=0;
while((tl= fGetc(fp))!= 0x0d)
time ++;
i=time;
fseek (fp,35L,0) ;
for(;i>0;i--) fputc(0x00,fp);
if(time==1) bc[1]= 0x60;
for(;bc[1]<= 0x60; bc[1]++)
for(bc[0]= 0x21; bc[0]<= 0x60; bc[0]++)
{
tl=0;
for(i=0; i<time; i++) tl=tl^bc;
chh=(tl^0x2d);
if(chh<0x20) chh=chh+0x20;
if(chh==ch)
{
printf("\n The file's CRC is: " ) ;
for(i=time; i>0;i--) printf("%c",bc[i-1]) ;
}
}
fclose(fp) ;
return 0;
} |