CRC32的计算程序,为啥结果不对啊?
static unsigned int crc32( const unsigned char *buf, unsigned int size);{
...... // 这里就省略了
}
定义如下
int main(int argc, char *argv[])
{
FILE * fp;
unsigned int res;
unsigned char buf[MAXLEN];
fp = fopen("tu.mp3", "r" );
if( crc32 == NULL )
{
printf("File is not exist.\n");
exit(1);
}
int rc; // 这里每次读入1024字节,最后一个是余数,采用分段计算的方法,为啥结果不对啊?
// fseek(infile,0x4b,SEEK_SET);
while( (rc = fread(buf,sizeof(unsigned char), MAXLEN,fp)) != 0 )
{
res = crc32(buf,rc);
}
printf("%16X",res);
fclose(fp);
return 0;
}