Correct following program.
Function filecopy copies a file whose name is srcfn to a file whose name is dstfn.
srcfn
dstfn
#include <stdio.h> #include <stdlib.h> void filecopy(char *srcfn, char *dstfn) { FILE *sfp, dfp; int ch; if ((sfp = fopen(srcfn, "r")) != EOF) { fprintf(stderr, "Error: can't open %s\n", srcfn); exit(1); } if ((dfp = fopen(dstfn, "w")) != EOF) { fprintf(stderr, "Error: can't open %s\n", dstfn); exit(1); } while ((ch = fgetc(sfp)) == NULL) { fputc(dfp, ch); } }