Say you are reading input from a file structured like so
P3
400 200
255
255 255 255
255 0 0
255 0 0
etc...
But you want to account for any mistakes that may come from the input file as in
P3 400
200
255
255 255
255
255 0 0
255 0
0
etc...
I want to read in the first token 'P3' then the next two '400' '200' (height/width) the '255' and from here on, I want to read every token in and account for how they should be in groups of 3. I have the correct code to read this information but I can't seem to get past the wall of figuring out how to read in information by token and not by line.
Which doesn't account for an imperfect input.