Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Best way to get/store data from a file?

This topic is 5979 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am a currentlly some sort of newbie in c++. I am up to the part in my engine were i need to get a mosters name... like its Name, Damage, Defense e.t.c I know how to use ifsteam/ofstream, but i need a idea how to store them and best way to recall them Like storing as Name|str|mon . any comments?

Share this post

Link to post
Share on other sites
you can store them any way you want, but it''s a little easier to store them seperated by line breaks. for example:



then you can just read them with something like this:

MonsterType monster[NUM_MONSTERS];
int x = 0;

theFile >> monster[x].name;
theFile >> monster[x].damage;
theFile >> monster[x].defense;

where theFile has been declared as an fstream object, and of course MonsterType is your monster struct/class.

hope this helps.


Share this post

Link to post
Share on other sites
I don''t know exactly what do you mean but I would create a file where the monster are saved and then when I need it i simply load the data into the memory to some kind of structure.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!