Hello
I am getting the above error message with my program. The line giving the error is marked.
What I am trying to do is create a file, (new.ppm) and have it then returned onto stdout.
FILE *fp;
fp = fopen("new.ppm", "w+"); //creates the new file
fprintf(fp, "P3\n%d %d\n255\n", harg, warg);
while (hcount < harg){
while (wcount < warg){
fprintf(fp, "%d ", cr);
fprintf(fp, "%d ", cb);
fprintf(fp, "%d ", cg);
wcount += 1;
}
fprintf(fp, "\n");
wcount = 0;
hcount += 1;
}
char buf[1024];
int buflen;
while((buflen = read(fp, buf, 1024)) > 0) //this line is throwing the error.
{
write(1, buf, buflen);
}
fclose(fp); //close the file
Any help you can provide is greatly appreciated,
Thanks.