...
Code Block | ||
---|---|---|
| ||
int copy_file(FILE *src, FILE *dst, size_t bufsize) {
if (bufsize == 0) {
/* Handle Error */
}
char *buf = (char *)malloc(bufsize);
if (!buf) {
return -1;
}
while (fgets(buf, bufsize, src)) {
fputs(buf, dst);
}
/* ... */
free(buf);
return 0;
}
|
...