S
sophia
Dear all,
the following is the file compression program ,using elimination of
spaces, which I saw in a book
#include<stdio.h>
#include<stdlib.h>
int main(int argc,char * argv[])
{
FILE* fs,*ft;
fs = fopen(argv[1],"r");
if(fs == NULL)
{
printf("\n Cannot open the file %s",argv[1]);
exit(1);
}
ft = fopen(argv[2],"w");
if(fs == NULL)
{
printf("\n Cannot open the file %s",argv[2]);
exit(1);
}
while( (ch=fgetc(fs)) != EOF)
{
if(ch == 32)
{
if( (ch=fgetc(fs)) != EOF)
fputc(ch+127,ft);
}
else
fputc(ch,ft);
}
fclose(fs);
fclose(ft);
return EXIT_SUCCESS;
}
Now my questions are as as follows
1) Is there any other simpler method to compress text files, similar
to the above program(Other than standard algorithms like huffman,LZW)
the following is the file compression program ,using elimination of
spaces, which I saw in a book
#include<stdio.h>
#include<stdlib.h>
int main(int argc,char * argv[])
{
FILE* fs,*ft;
fs = fopen(argv[1],"r");
if(fs == NULL)
{
printf("\n Cannot open the file %s",argv[1]);
exit(1);
}
ft = fopen(argv[2],"w");
if(fs == NULL)
{
printf("\n Cannot open the file %s",argv[2]);
exit(1);
}
while( (ch=fgetc(fs)) != EOF)
{
if(ch == 32)
{
if( (ch=fgetc(fs)) != EOF)
fputc(ch+127,ft);
}
else
fputc(ch,ft);
}
fclose(fs);
fclose(ft);
return EXIT_SUCCESS;
}
Now my questions are as as follows
1) Is there any other simpler method to compress text files, similar
to the above program(Other than standard algorithms like huffman,LZW)