1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <stdio.h> #include "sb.h" FILE* getfile(int argc, char** argv){ if (argc >= 2) return fopen(argv[1], "r"); else return stdin; } FILE* in; int main(int argc, char** argv){ int c; in = getfile(argc, argv); if (in == NULL){ perror(argv[1]); return 1; } while ( (c = fgetc(in)) != EOF){ } }