int i,j;
BYTE ch=0,buffer[2];
unsigned char vanl[3],tch,R_van=0;
WORD *p1;
int remain=0,byte_num=0;
fseek(fout,12L,0);//Ô¤Áô±íÍ·¿Õ¼ä
for(i=0;i<f_head.SourceSignalNum;i++)//fwrite()º¯ÊýÓÐBug²»ÄÜÕûÌåÊä³öÒ»¸ö½á¹¹Ìå
{
fwrite(&f_table
.SourceSignal_CodeLength,1,1,fout);//写码表
fwrite(&f_table.CodeBits,2,1,fout);
}
f_head.hfSize=12;
while(!feof(fp))
{
/*读源文件
写霍夫曼文件*
p1=(WORD*)(&vanl[0]);
buffer[0]=fgetc(fp);
buffer[1]=buffer[0]&0x0F;//buffer[1] lower 4 bits
buffer[0]>>=4;//buffer[0] higher 4 bits
for(i=0;i<2;i++)
{
ch=buffer;
*p1 = temp_table[ch].HCode;
byte_num=((int)temp_table[ch].length+remain)/8;
tch=vanl[1];
*p1=*p1<<(8-remain);
tch=tch>>remain;
vanl[2]=tch|R_van;
for(j=0;j<byte_num;j++)
{
fwrite(&vanl[2-j],1,1,fout);
f_head.hfSize++;
}
R_van=vanl[2-j];
remain=(temp_table[ch].length+remain) % 8;
}
代码如上,明明读了一个字节,却写入多次,怎么还压缩了,费解
[ 此帖被光子vs电子在2008-04-10 23:17重新编辑 ]