當前位置:首頁 » 文件管理 » c文件夾壓縮

c文件夾壓縮

發布時間: 2023-05-28 09:31:22

Ⅰ 有個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);

熱點內容
怎樣用windows伺服器搭建網站 發布:2025-02-08 12:27:38 瀏覽:530
android獲取音樂 發布:2025-02-08 12:26:05 瀏覽:961
存儲的數據可以復制嗎 發布:2025-02-08 12:20:22 瀏覽:852
scraino編程 發布:2025-02-08 11:59:41 瀏覽:265
我的世界伺服器進不去該怎麼辦 發布:2025-02-08 11:47:41 瀏覽:236
linux的telnet 發布:2025-02-08 11:47:36 瀏覽:288
壓縮袋打折 發布:2025-02-08 11:46:02 瀏覽:259
c語言結構體題目 發布:2025-02-08 11:46:01 瀏覽:339
如何svn限制一些外網不能訪問 發布:2025-02-08 11:46:00 瀏覽:992
伺服器外網ip咋配置 發布:2025-02-08 11:42:19 瀏覽:643