/* @(#)filter.c 1.1 12/9/92 */ /* * File : filter.c * * Input : File containing M lines of N strings each * Output : File containing, for each line, the strings * + 1 to - * * Usage : Usage : filter \n"); * * Input: stdin * Output: stdout * * = total number of strings to read on a line. * = skip the first strings. * * Andrew H. Fagg * Center for Neural Engineering * Computer Science Department * University of Southern California * Henry Salvatori #300 * Los Angeles, CA 90089-0781 * * ahfagg@pollux.usc.edu * * * HISTORY * Date Author Description * -------- ----------------- -------------------------------- * 12/05/92 Andrew H. Fagg Doc update. * 01/15/92 Andrew H. Fagg Original. * */ #include main(argc, argv) int argc; char *argv[]; { int total; int skip; char buf[100]; int i; /* Check number of args. */ if(argc != 3) { printf("Usage : filter \n"); exit(0); } if(sscanf(argv[1], "%d", &total) != 1) { printf("Error in parsing total\n"); exit(0); } if(sscanf(argv[2], "%d", &skip) != 1) { printf("Error in parsing skip\n"); exit(0); } /* For each line in the file. */ while(1) { /* Skip first few strings. */ for(i = 0; i < skip; ++i) { if(scanf("%s", buf) != 1) return(1); } /* Copy the remaining strings up to */ for(i = 0; i < total - skip; ++i) { if(scanf("%s", buf) != 1) return(1); printf("%s ", buf); } /* Eat the other characters. */ while(getchar() != '\n'); printf("\n"); } }