Quickly read pgm header with comments in C
Posted
by Vi
on Stack Overflow
See other posts from Stack Overflow
or by Vi
Published on 2010-04-02T10:28:45Z
Indexed on
2010/04/02
10:33 UTC
Read the original article
Hit count: 335
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)?
© Stack Overflow or respective owner