B
Bill Cunningham
I'm hoping that someone can point out the error I'm getting here and seg
fault. I find it very hard to read code posted by these newsreaders. I'm
using OE. I hope someone can read this code.
Bill
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main()
{
errno=0;
size_t nread, nwrite, nbytes;
nread = nwrite = nbytes = 0;
char buf[9000] = { 0 };
FILE *fp, *fp2;
if ((fp = fopen("6", "rb")) == NULL)
perror("fopen 1");
if ((fp2 = fopen("a", "wb")) == NULL)
perror("fopen 2");
do {
nread = fread(buf, sizeof(buf), 1, fp);
nwrite = fwrite(buf, sizeof(buf), nread, fp2);
} while (!feof(fp));
fclose(fp);
fclose(fp2);
printf("%d %d\n", nread, nwrite);
printf("%s\n",strerror(errno));
return 0;
}
fault. I find it very hard to read code posted by these newsreaders. I'm
using OE. I hope someone can read this code.
Bill
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main()
{
errno=0;
size_t nread, nwrite, nbytes;
nread = nwrite = nbytes = 0;
char buf[9000] = { 0 };
FILE *fp, *fp2;
if ((fp = fopen("6", "rb")) == NULL)
perror("fopen 1");
if ((fp2 = fopen("a", "wb")) == NULL)
perror("fopen 2");
do {
nread = fread(buf, sizeof(buf), 1, fp);
nwrite = fwrite(buf, sizeof(buf), nread, fp2);
} while (!feof(fp));
fclose(fp);
fclose(fp2);
printf("%d %d\n", nread, nwrite);
printf("%s\n",strerror(errno));
return 0;
}