-
parsing a file
I'm trying to make a map loader for a simple game, but I'm confused on how to do so. I keep on running into the error of loading a float into a char, or vice versa. I also want to try and make it so whitespace doesn't matter. Can anyone lead me to a tutorial on how to read files like this? All I can ever find is simple hello world ifstream tutorials.
-
I'd probably read chunks into memory and parse from there. True, less efficient for processing, but much easier.
-
If the file is small enough, you can load the entire thing into memory and parse it.
When it comes to whitespace, just remember to read character-by-character and skip them if it's equal to a whitespace.
And about the whole float vs char thing - think of a design and a layout for your file and stick with it. That's the easiest way since you know how the file layout will be and won't have those problems since you know what is exactly what type.