#include #include #include #include int main(int argc, char **argv) { if (argc <= 1) { fprintf(stderr, "usage: %s [ul]\n", argv[0]); exit(EXIT_FAILURE); } char *mode = argv[1]; bool upper; switch (mode[0]) { case 'u': upper = true; break; case 'l': upper = false; break; default: fprintf(stderr, "usage: %s [ul]\n", argv[0]); exit(EXIT_FAILURE); } int c; while ((c = fgetc(stdin)) != EOF) { if (upper) putc(toupper(c), stdout); else putc(tolower(c), stdout); } if (ferror(stdin)) { fprintf(stderr, "oops\n"); exit(EXIT_FAILURE); } }