Skip to content

Commit

Permalink
Use the return of fscanf
Browse files Browse the repository at this point in the history
  • Loading branch information
nohal committed Mar 19, 2016
1 parent 33d5224 commit f4f723b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ppm2bsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,25 @@ extern int main (int argc, char *argv[])
perror(argv[2]);
exit(1);
}
fscanf(ppm, "P%d\n", &magic);
fscanf(ppm, "%d %d\n", &image.width, &image.height);
fscanf(ppm, "%d\n", &max_sample);
int res = fscanf(ppm, "P%d\n", &magic);
if (res == EOF )
{
perror(argv[2]);
exit(1);
}
res = fscanf(ppm, "%d %d\n", &image.width, &image.height);
if (res == EOF )
{
perror(argv[2]);
exit(1);
}
res = fscanf(ppm, "%d\n", &max_sample);
if (res == EOF )
{
perror(argv[2]);
exit(1);
}

start_of_raster = ftell(ppm);

/* Count unique colors in the PPM file */
Expand Down

0 comments on commit f4f723b

Please sign in to comment.