传播优秀 Word 版文档 ,希望对您有帮助,可双击去除!
unsigned char b; /*the charactor*/
long count; /*the frequency*/
long parent,lch,rch; /*make a tree*/
char bits[256]; /*the haffuman code*/
}
header[512],tmp;
void yasuo() /*压缩*/
{
char filename[255],outputfile[255],buf[512];
unsigned char c; char wenjianming[255];
long i,j,m,n,f;
long min1,pt1,flength;
FILE *ifp,*ofp;
printf("输入文件地址及文件名:");
gets(filename);
ifp=fopen(filename,"rb"); /*打开源文件*/
while(ifp==NULL)
{ printf("打开文件出错\n");
printf("重新输入文件地址及文件名");
gets(filename);
ifp=fopen(filename,"rb");
}
printf("输入压缩后的文件地址和文件名及后缀:");
gets(wenjianming);
ofp=fopen(wenjianming,"wb"); /*创建并打开目的文件*/
while(ofp==NULL)
{printf("重新输入压缩后的文件地址和文件名及后缀:");
ofp=fopen(wenjianming,"wb");
}
flength=0;
while(!feof(ifp)) /*读取 ifp 文件*/
{
fread(&c,1,1,ifp); /*按位读取*/
header[c].count++;
flength++;
}
flength-1;
header[c].count-1; /*读取文件结束*/
for(i=0;i<512;i++) /*构造哈弗曼树*/
{
if(header[i].count!=0)
header[i].b=(unsigned char)i;
else
评论1
最新资源