c文件夹压缩
Ⅰ 有个C程序,用来批量压缩文件夹里的文件压缩为rar格式,出了点问题
大概看了一下,有几个疑问:
1、rar软件也在压缩文件夹里吗?因为你写的是./rar
2、system函数的参数似乎有问题,最外面的两个strcat是不是可以去掉了
我现在没有环境,你可以用gdb跟一下,很容易找到问题所在的
Ⅱ 360压缩怎样压缩c语言程序
1、在c语言文件或存有c语言文件的文件夹上,
右单击鼠标,在弹出的菜单上选择压缩到"xxx.zip"
2、打开360压缩软件,在工具栏上单击添加,选择
c语言文件或文件夹,然后单击工具栏上的一键压缩。
Ⅲ c盘属性里的压缩驱动器以减少磁盘空间的前面可以打勾选吗
此功能适用于CPU强劲且为NTFS文件系统的计算机,选择后,操作系统会把系统盘上的数据全部压缩(对压缩包文件无效),可以节省部分空间。但结果是以后系统运行的时候速度大大降低(因为每次都要解压)。
如果要用系统自带的压缩方法,必须要有先决条件,那就是磁盘的文件系统格式应该为NTFS类型,如果是FAT32或其它类型,就不能用此方式压缩了,详细步骤:
1、查看磁盘文件系统格式类型方法:从桌面进入“我的电脑”后,在要压缩的系统盘(一般为C盘)上右键,选择菜单中的“属性”这一项。
Ⅳ (20分)用C语言编译的文件压缩解压缩程序
是用霍夫曼树做的
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
struct head
{
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 compress()
{
char filename[255],outputfile[255],buf[512];
unsigned char c;
long i,j,m,n,f;
long min1,pt1,flength;
FILE *ifp,*ofp;
printf("source filename:");
gets(filename);
ifp=fopen(filename,"rb");
if(ifp==NULL)
{
printf("source file open error!\n");
return;
}
printf("destination filename:");
gets(outputfile);
ofp=fopen(outputfile,"wb");
if(ofp==NULL)
{
printf("destination file open error!\n");
return;
}
flength=0;
while(!feof(ifp))
{
fread(&c,1,1,ifp);
header[c].count++;
flength++;
}
flength--;
header[c].count--;
for(i=0;i<512;i++)
{
if(header[i].count!=0) header[i].b=(unsigned char)i;
else header[i].b=0;
header[i].parent=-1;
header[i].lch=header[i].rch=-1;
}
for(i=0;i<256;i++)
{
for(j=i+1;j<256;j++)
{
if(header[i].count<header[j].count)
{
tmp=header[i];
header[i]=header[j];
header[j]=tmp;
}
}
}
for(i=0;i<256;i++) if(header[i].count==0) break;
n=i;
m=2*n-1;
for(i=n;i<m;i++)
{
min1=999999999;
for(j=0;j<i;j++)
{
if(header[j].parent!=-1) continue;
if(min1>header[j].count)
{
pt1=j;
min1=header[j].count;
continue;
}
}
header[i].count=header[pt1].count;
header[pt1].parent=i;
header[i].lch=pt1;
min1=999999999;
for(j=0;j<i;j++)
{
if(header[j].parent!=-1) continue;
if(min1>header[j].count)
{
pt1=j;
min1=header[j].count;
continue;
}
}
header[i].count+=header[pt1].count;
header[i].rch=pt1;
header[pt1].parent=i;
}
for(i=0;i<n;i++)
{
f=i;
header[i].bits[0]=0;
while(header[f].parent!=-1)
{
j=f;
f=header[f].parent;
if(header[f].lch==j)
{
j=strlen(header[i].bits);
memmove(header[i].bits+1,header[i].bits,j+1);
header[i].bits[0]='0';
}
else
{
j=strlen(header[i].bits);
memmove(header[i].bits+1,header[i].bits,j+1);
header[i].bits[0]='1';
}
}
}
fseek(ifp,0,SEEK_SET);
fwrite(&flength,sizeof(int),1,ofp);
fseek(ofp,8,SEEK_SET);
buf[0]=0;
f=0;
pt1=8;
while(!feof(ifp))
{
c=fgetc(ifp);
f++;
for(i=0;i<n;i++)
{
if(c==header[i].b) break;
}
strcat(buf,header[i].bits);
j=strlen(buf);
c=0;
while(j>=8)
{
for(i=0;i<8;i++)
{
if(buf[i]=='1') c=(c<<1)|1;
else c=c<<1;
}
fwrite(&c,1,1,ofp);
pt1++;
strcpy(buf,buf+8);
j=strlen(buf);
}
if(f==flength) break;
}
if(j>0)
{
strcat(buf,"00000000");
for(i=0;i<8;i++)
{
if(buf[i]=='1') c=(c<<1)|1;
else c=c<<1;
}
fwrite(&c,1,1,ofp);
pt1++;
}
fseek(ofp,4,SEEK_SET);
fwrite(&pt1,sizeof(long),1,ofp);
fseek(ofp,pt1,SEEK_SET);
fwrite(&n,sizeof(long),1,ofp);
for(i=0;i<n;i++)
{
fwrite(&(header[i].b),1,1,ofp);
c=strlen(header[i].bits);
fwrite(&c,1,1,ofp);
j=strlen(header[i].bits);
if(j%8!=0)
{
for(f=j%8;f<8;f++)
strcat(header[i].bits,"0");
}
while(header[i].bits[0]!=0)
{
c=0;
for(j=0;j<8;j++)
{
if(header[i].bits[j]=='1') c=(c<<1)|1;
else c=c<<1;
}
strcpy(header[i].bits,header[i].bits+8);
fwrite(&c,1,1,ofp);
}
}
fclose(ifp);
fclose(ofp);
printf("compress successfully!\n");
return;
}
void uncompress()
{
char filename[255],outputfile[255],buf[255],bx[255];
unsigned char c;
long i,j,m,n,f,p,l;
long flength;
FILE *ifp,*ofp;
printf("source filename:");
gets(filename);
ifp=fopen(filename,"rb");
if(ifp==NULL)
{
printf("source file open error!\n");
return;
}
printf("destination filename:");
gets(outputfile);
ofp=fopen(outputfile,"wb");
if(ofp==NULL)
{
printf("destination file open error!\n");
return;
}
fread(&flength,sizeof(long),1,ifp);
fread(&f,sizeof(long),1,ifp);
fseek(ifp,f,SEEK_SET);
fread(&n,sizeof(long),1,ifp);
for(i=0;i<n;i++)
{
fread(&header[i].b,1,1,ifp);
fread(&c,1,1,ifp);
p=(long)c;
header[i].count=p;
header[i].bits[0]=0;
if(p%8>0) m=p/8+1;
else m=p/8;
for(j=0;j<m;j++)
{
fread(&c,1,1,ifp);
f=c;
itoa(f,buf,2);
f=strlen(buf);
for(l=8;l>f;l--)
{
strcat(header[i].bits,"0");
}
strcat(header[i].bits,buf);
}
header[i].bits[p]=0;
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(strlen(header[i].bits)>strlen(header[j].bits))
{
tmp=header[i];
header[i]=header[j];
header[j]=tmp;
}
}
}
p=strlen(header[n-1].bits);
fseek(ifp,8,SEEK_SET);
m=0;
bx[0]=0;
while(1)
{
while(strlen(bx)<(unsigned int)p)
{
fread(&c,1,1,ifp);
f=c;
itoa(f,buf,2);
f=strlen(buf);
for(l=8;l>f;l--)
{
strcat(bx,"0");
}
strcat(bx,buf);
}
for(i=0;i<n;i++)
{
if(memcmp(header[i].bits,bx,header[i].count)==0) break;
}
strcpy(bx,bx+header[i].count);
c=header[i].b;
fwrite(&c,1,1,ofp);
m++;
if(m==flength) break;
}
fclose(ifp);
fclose(ofp);
printf("Uncompress successfully!\n");
return;
}
int main()
{
int c;
printf("1--Compress file\n");
printf("2--Uncompress file\n");
printf("Select 1 or 2:");
c=getch();
printf("%c\n",c);
if(c=='1') compress();
else if(c=='2') uncompress();
return 0;
}
Ⅳ 如何用C语言解压缩文件
如果你自己设计算法,就另当别论,如果想利用第3方的算法,我推荐用zlib,生成的压缩包是流行的zip格式.源代码很好找(www.zlib.net)
Ⅵ 为什么电脑在解压缩文件时,会占用C盘的空间
原因:因为压缩文件在打开时会首先解压在临时文件夹,一般压缩软件默认的临时文件夹在C盘内,路径为“C:UsersADMINI~1AppDataLocalTemp”。
解决:可以在压缩软件的设置内取消临时文件夹,操作如下:
1、以压缩软件bandizip为例,首先打开一个压缩文件,在上方的菜单栏中依次打开“选项”>“设置”;
Ⅶ windows7能不能将c盘中的windows文件夹进行压缩
压缩分为打包氏派孙压缩这个是不可以的,因为该文件夹属于系统文件夹,打包压缩对于其他电脑硬件的驱动程序识别不了,所以没有意义。x0dx0a压缩删除无用垃圾释放更多空间是可以的。x0dx0a具体如下:x0dx0a1.C:WindowsWebWall*** (Windows自带墙纸)推荐转移。x0dx0a2.C: 下搜索输入 ati*.inf (14.6M) nv*.inf(94.9M) (A卡用户删N、N卡用户删A)、搜索输入 mdm*.inf (21.6M) 现在已没用的东西删、搜索输入 prn*.inf (781M) prn 开头的全部都是打印机驱动,相信大多数人都是用不上的。就是有打印机,买的时候也会带有驱动,删除。x0dx0a注意:prnms001.inf/prnoc001.inf/prnms002.inf 这三个并不是打印机驱动,建议保留。x0dx0a3.C:Boot (13.3M) 这个里面是不同语言的Windows启动界面,除zh-CN外均可删除。x0dx0a4.C:perflogsSystemDiagnostics (9.39M) 这个是系统测试之后的测试记录文件存放处,删。羡册x0dx0a5.C:WindowsDownloaded Installations 有一些程序(Dreamweaver??)安装的时候会把安装文件解压至此文件夹里面。可以安全删除,几十M到几百M不等。x0dx0a6.C:WindowsHelp (66.7M) 帮助全部删除。x0dx0a7. C:WindowsIMEIMESC5 微软拼音输入法(74.5M)可留。x0dx0aC:WindowsIMEIMEJP10 日文输入法(37.8M) 删。x0dx0aC:WindowsIMEimekr8 韩文输入法(2.86M) 删。x0dx0aC:WindowsIMEIMETC10 繁中输入法(21.6M) 删。x0dx0a8. C:WindowsInstaller 已安装程序的卸载修改时所需程序,如果删除了,有些程序卸载歼链和修改就会有问题。x0dx0a9.C:Windowswinsxs 这个不能删除,但是可以压缩,压缩后大小为2.48G.节省空间近1G。x0dx0a10.C:WindowswinsxsBackup(备份文件,占用354MB); 删除。
Ⅷ c语言 文本文件压缩
再发次,有80分呢哎
Ⅸ C# zip 文件夹压缩问题
string startPath = @"c:\example\start";string zipPath = @"c:\example\result.zip";string extractPath = @"c:\example\extract";ZipFile.CreateFromDirectory(startPath, zipPath);ZipFile.ExtractToDirectory(zipPath, extractPath);