|
|
1.1 ! root 1: #include <stdio.h> ! 2: ! 3: main() ! 4: { ! 5: FILE *fpin, *fpout; ! 6: int inerr = 0; ! 7: int outerr = 0; ! 8: int word; ! 9: char infile[20], outfile[20]; ! 10: ! 11: printf("Name data file you wish to copy:\n"); ! 12: gets(infile); ! 13: printf("Name new file:\n"); ! 14: gets(outfile); ! 15: ! 16: if ((fpin = fopen(infile, "r")) != NULL) { ! 17: if ((fpout = fopen(outfile, "w")) != NULL) { ! 18: for (;;) { ! 19: word = fgetw(fpin); ! 20: if (ferror(fpin)) { ! 21: clearerr(fpin); ! 22: inerr++; ! 23: } ! 24: if (feof(fpin)) ! 25: break; ! 26: fputw(word, fpout); ! 27: if (ferror(fpout)) { ! 28: clearerr(fpout); ! 29: outerr++; ! 30: } ! 31: } ! 32: } else { ! 33: printf ! 34: ("Cannot open output file %s\n", ! 35: outfile); ! 36: exit(1); ! 37: } ! 38: } else { ! 39: printf("Cannot open input file %s\n", infile); ! 40: exit(1); ! 41: } ! 42: printf("%d - read error(s) %d - write error(s)\n", ! 43: inerr, outerr); ! 44: exit(0); ! 45: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.