Alternative way to process the command line options, using strcmp(3): for (; *argv && **argv=='-'; argc--,argv++) { cp = *argv; if (strcmp(cp, "-") == 0) { /* ``-'' is no option but use stdin as first file */ break; } else if (strcmp(cp, "-x") == 0) { xflag = 1; } else if (strncmp(cp, "-c", 2) == 0) { if (cp[2]) { word = cp + 2; } else if (*++argv) { argc--; word = *argv; } else { usage(); } } else { fprintf(stderr, "Unknown option `%s'\n", cp); usage(); } }