I would like to import a text file with weapon data for an RPG.
I was thinking I could read the file in the class constructor. It works but I am not sure how to pull specific lines from the text file as I may need them.
Plus there is issue that the data imported data that is a string. Makes it difficult to calculate damage. Would I just convert the string?
You may want to consider just storing objects of the weapons in a file rather than the data.
This has the advantage of not having to run through the file, decorating the objects as you read through it.
You will need to write / read in binary mode and you can use sizeof() to read an entire object at once.
Hope that's not too complicated for you - but I would think this is more effective than storing the data in a plain text file. It also limits users with no programming knowledge of tampering with the weapons data, it's not exactly security, but at least it hides the implementation a bit.