B
Bill Cunningham
Ok after looking a Nick's old post again, I decided to try my own
copy. It seems to fill better with my style. Now it compiles can
copies fine. The thing is it hasn't been tested as to whether or not
it copied actual 2048 bytes at a time. I will submit it for review...
#include <stdio.h>
int main()
{
size_t nread = 0;
char buf[2048];
FILE *fpi, *fpo;
if ((fpi = fopen("t", "rb")) == NULL)
return -1;
if ((fpo = fopen("z", "wb")) == NULL)
return -2;
do {
nread = fread(buf, sizeof(buf), 1, fpi);
if (ferror(fpi))
return -3;
fwrite(buf, sizeof(buf), nread, fpo);
if (ferror(fpo))
return -4;
}
while (!feof(fpi));
fclose(fpi);
fclose(fpo);
return 0;
}
copy. It seems to fill better with my style. Now it compiles can
copies fine. The thing is it hasn't been tested as to whether or not
it copied actual 2048 bytes at a time. I will submit it for review...
#include <stdio.h>
int main()
{
size_t nread = 0;
char buf[2048];
FILE *fpi, *fpo;
if ((fpi = fopen("t", "rb")) == NULL)
return -1;
if ((fpo = fopen("z", "wb")) == NULL)
return -2;
do {
nread = fread(buf, sizeof(buf), 1, fpi);
if (ferror(fpi))
return -3;
fwrite(buf, sizeof(buf), nread, fpo);
if (ferror(fpo))
return -4;
}
while (!feof(fpi));
fclose(fpi);
fclose(fpo);
return 0;
}