-5
이 코드는 C로 작성했습니다. 압축을 풀고 싶지만 그렇게 할 수 없습니다.C에서 파일 압축 해제하는 방법
이 점에 대해 도와주세요. 폴더에있는 텍스트 파일의 압축을 풀고 싶습니다. 우리는 위의 가상의 주사선 실행 길이 인코딩 (RLE) 데이터 압축 알고리즘을 적용하면 WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW : 나는 위키 피 디아에서 너무
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char find[100000];
char* StrCompress(char myStr[]);
int go()
{
FILE* custom = NULL;
custom = fopen("newfile.txt", "r");
if(custom == NULL)
{
printf("\n Unable to open file testing.txt");
return 1;
}
FILE* future = NULL;
future = fopen("new.txt", "w");
if(future== NULL)
{
printf("\n Unable to open file new.txt");
return 1;
}
while(fscanf(custom, "%s", find)!=EOF)
{
//Use data read in find here
printf("%s", StrCompress(find));
fprintf(future, "%s ", StrCompress(find));
}
fclose(custom);
fclose(future);
}
char* StrCompress(char myStr[])
{
char *s = myStr;
char *r, *p;
int count, i;
while (*s)
{
count = 1;
while (*s == *(s+1) && *s)
{
count++;
s++;
}
if (count > 1)
{
*(s - count + 2) = count + '0';
for (i = 0; i < count - 2; i++)
{
p = s + 1;
r = s;
while (*r)
*r++ = *p++;
s--;
}
}
s++;
}
return myStr;
}
int main()
{
go();
return 0;
}
이 질문은 "내 코드를 작성해주세요."라는 질문과 관련이 없기 때문에 주제가 아닌 것처럼 보입니다. – alk
파일은 어떻게 압축됩니까? 너 뭐 해봤 니? –
예 압축 파일을 압축하는 데 RLE 메서드를 사용했습니다 –