Advertisement
Guest User

decompression

a guest
Nov 30th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. //--------------------Decompressing method if the arguement being processed is d--------------------
  2.     if(strcmp(argv[1],"d") == 0)
  3.     {
  4.         //While there are characters in the input file
  5.         while((x = getc(inFile)) != EOF)
  6.         {  
  7.             //Put the character in the output file
  8.                 putc(x, outFile);
  9.            
  10.             //If the previous character is equal to the current character
  11.             if(x == z)
  12.                 {  
  13.                 //Set x equal to the next character
  14.                 x = getc(inFile);
  15.  
  16.                 //If it is the same character again
  17.                         while(x != 0)
  18.                         {                  
  19.                     putc(z,outFile);
  20.                     //Decrement the special character
  21.                             x--;
  22.                         }
  23.                         //Put the repeating character to the output file
  24.                 putc(z,outFile);
  25.                 }
  26.             //Assign the previous character to x
  27.                 z = x;
  28.            
  29.         }
  30.         counter = 0;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement