Listing 5 A Function that copies a file via block I/0
/* copy2.c */ #include <stdio.h> int copy(FILE *dest, FILE *source) { size_t count; static char buf[BUFSIZ]; while (!feof(source)) { count = fread(buf,l,BUFSIZ,source); if (ferror(source)) return EOF; If (fwrite(buf,l,count,dest) != count) return EOF; } return 0; } /* End of File */