Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > simple file com...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 25130 of 27670
Post > Topic >>

simple file compression program

by sophia <sophia.agnes@[EMAIL PROTECTED] > Mar 26, 2008 at 01:09 PM

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)
 




 9 Posts in Topic:
simple file compression program
sophia <sophia.agnes@[  2008-03-26 13:09:35 
Re: simple file compression program
mstorkamp@[EMAIL PROTECTE  2008-03-26 13:24:45 
Re: simple file compression program
roberson@[EMAIL PROTECTED  2008-03-26 20:40:29 
Re: simple file compression program
"Malcolm McLean"  2008-03-26 22:14:56 
Re: simple file compression program
"Bartc" <bc@  2008-03-26 22:15:24 
Re: simple file compression program
Barry Schwarz <schwarz  2008-03-26 22:11:54 
Re: simple file compression program
sophia <sophia.agnes@[  2008-03-27 02:45:44 
Re: simple file compression program
santosh <santosh.k83@[  2008-03-27 15:43:45 
Re: simple file compression program
Barry Schwarz <schwarz  2008-03-27 18:48:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 22:10:50 CDT 2008.