I'm trying to parse through a ppm file, but first need to verify if the header info is correct. A ppm file may have the following formats:
P3
100 100
255
data...
or
p3
100 100
255
data...
I'm using fscanf (file_stream, "P3 %d %d %d", &width, &height, &max_colour); to verify the header info. What I'd like to know is, how to move on to reading the data (char by char) after verifying the header info.
Assuming the header tells you the size of the data then allocate a block of memory that is large enough and use fread() to read it in a single call - this is MUCH faster than reading a byte at a time.