Listing 3: #include #include main(int argc, char *argv[]) { copy_it(argv[1], argv[2]); end_it("copy is done\n"); } copy_it(char FileIn[55], char FileOut[55]) { FILE *fi; FILE *fo; int gc; /* The next 2 lines fixed the problem */ /* NOT VERY ELEGANT BUT IT WORKS! */ if (*FileIn == *FileOut) end_it("ABORT: Make first letters of names different\n"); if ((fi = fopen(FileIn, "rb")) == NULL) end_it("File not found\n"); if ((fo = fopen(FileOut, "wb")) == NULL) { fclose(fi); end_it("No output\n"); } while (!feof(fi)) { gc = getc(fi); if (!feof(fi)) putc(gc, fo); } fclose(fi); fclose(fo); } /* IF FILEIN = FILEOUT, AND FILE IS LARGER THAN ABOUT 2-3K, 6 YOU WILL DAMAGE DIRECTORY TABLE! */ static end_it(s) char *s; /* String to display to User */ { /* Display string passed and simply abort */ fprintf(stdout, s); exit (0); }