// The program parses the input switches to sort // supports command lines such as sort -r -u -n // but not sort -run which you will need for // the Lab3 #include int main(int argc, char *argv[]) { int unique, reverse, numsort; char *progname; progname = argv[0]; // run through the input commands looking // for switches while((argc > 1) && (argv[1][0] == '-')) { // argv[1][1] is the actual option switch (argv[1][1]) { case 'r': printf("Switch is %c\n", argv[1][1]); reverse = 1; break; case 'u': printf("Switch is %c\n", argv[1][1]); unique = 1; break; case 'n': printf("Switch is %c\n", argv[1][1]); numsort = 1; break; default: printf("Usage: bad option %s\n", argv[1]); break; } // decrement the number of arguments left // increment the argv pointer to the next argument argc--; argv++; } // other processing return(0); }