|
|
1.1 ! root 1: /* ! 2: * copy.c ! 3: * 11/4/92 ! 4: */ ! 5: ! 6: #include <unixstdio.h> ! 7: ! 8: extern void fatal(); ! 9: ! 10: FILE *ifp, *ofp; ! 11: ! 12: main(argc, argv) int argc; char *argv[]; ! 13: { ! 14: register int c; ! 15: ! 16: if (argc != 3) ! 17: fatal("Usage: copy in out"); ! 18: if ((ifp = fopen(argv[1], "r")) == NULL) ! 19: fatal("copy: cannot open input file"); ! 20: if ((ofp = fopen(argv[2], "w")) == NULL) ! 21: fatal("copy: cannot open input file"); ! 22: while ((c = getc(ifp)) != EOF) ! 23: putc(c, ofp); ! 24: printf("feof(ifp)=%d\n", feof(ifp)); ! 25: printf("ferror(ifp)=%d\n", ferror(ifp)); ! 26: printf("ferror(ofp)=%d\n", ferror(ofp)); ! 27: fclose(ifp); ! 28: fclose(ofp); ! 29: exit(0); ! 30: } ! 31: ! 32: /* VARARGS */ ! 33: void ! 34: fatal(msg) char *msg; ! 35: { ! 36: fprintf(stderr, "%s\n", msg); ! 37: exit(1); ! 38: } ! 39: ! 40: /* end of copy.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.