home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progc / itcdec89.arj / UNIQ.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-07  |  541 b   |  28 lines

  1. /* uniq.c
  2.  *
  3.  * filters out all duplicate lines -- assumes
  4.  * that file has been sorted first
  5.  */
  6.  
  7. #include<ctype.h>
  8. #include<string.h>
  9. #include<stdio.h>
  10.  
  11. void main(void);
  12.  
  13. char linebuffer[1000],oldlinebuffer[1000];
  14.  
  15. void main(void)
  16.     {
  17.     oldlinebuffer[0] = '\0';
  18.  
  19.     while(gets(linebuffer))
  20.         if(strcmp(linebuffer,oldlinebuffer))    
  21.             {   /* if no match, save copy   */
  22.             strcpy(oldlinebuffer,linebuffer);   
  23.             puts(linebuffer);   /* write line */
  24.             }
  25.     }
  26.  
  27.  
  28.