/* converts case of standard input to upper or lower, depending upon * the name the program was invoked with, and prints the results on * standard output. */ #include #include int main(int argc, char *argv[]) { char c; while (!isalpha(*argv[0]) && *argv[0] != '\0') argv[0]++; if (strcmp(argv[0], "upper") == 0) while ((c=getchar()) != EOF) putchar(toupper(c)); else if (strcmp(argv[0], "lower") == 0) while ((c=getchar()) != EOF) putchar(tolower(c)); else while ((c=getchar()) != EOF) putchar(c); if (c != '\n') putchar('\n'); return 0; }