Quickly read pgm header with comments in C
- by Vi
Quickly write PGM header is fprintf(f, "P5 %d %d 255\n", width, height);
Quickly read PGM header is fscanf(f, "P5%d%d%*d\n"); // now can read the data from f, but it fails when the header contains comments (like if saved by GIMP).
How to read PGM header in more compatible way (without a lot of code or extra dependencies, I don't want my program to cease being oneliner because of this)?