#include #include int main() { char c; int count = 0; int lcount = 0; int scount = 0; FILE *fpin, *fpout; if((fpin = fopen("input1.txt", "r")) == NULL){ fprintf(stderr, "Failed to open: input1.txt\n"); exit(1); } if((fpout = fopen("output1.txt", "w")) == NULL){ fprintf(stderr, "Failed to open: output1.txt\n"); fclose(fpin); exit(2); } while(fscanf(fpin, "%c", &c) == 1){ printf("%c", c); fprintf(fpout, "%c", c); count++; if(c == '\n') lcount++; if(c == ' ') scount++; } fprintf(stderr, "%d characters / %d lines / %d spaces are read and copied.\n", count, lcount, scount); fclose(fpin); fclose(fpout); return 0; }