Advertisement Jump to content


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



This topic is 5465 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

Hiya I''m doing AI for a sidescrolling yoshi''s island type ascii game and I''d like to store my information in external text files (just like 20 variables per AI type). I have the basic AI class done, but need a good way to read it in. I''ve been using fscanf for a while but have enountered some problems with formatting. What kind of file structure and functions do you guys usually use for file IO? Any suggestions? Basically I''d like to move away from fscanf if there''s something easier/more powerful. Thanks! Ben

Share this post

Link to post
Share on other sites
Might be better if you told us your formatting problems as i use fscanf religiously to load maps etc and never have a problem?

well lie, i did at the start until i sussed it

let me know

Share this post

Link to post
Share on other sites
You could store it in structs!
I made that one time and it is very simple because you get all the parameters you need in just one read! It may use more resources that you''ll need, but it''s much easier to handle...

Share this post

Link to post
Share on other sites
Using structures could make life easier as you can write the struct out to a binary file to prevent other people from messing with your settings. I've found the C I/O functions to be easier to use if im using binsry files but the C++ I/O streams are capable of reading/writing binary files also.

This is one way that you can do it (with C style I/O)

struct AIType
//your vars

//set the struct vars etc

//write the data out to a file
FILE *g_pFile = fopen("SomeFile", "wb");
fwrite(&g_AIType, sizeof(AIType), 1, g_pFile);

//then to read the data back in
g_pFile = fopen("SomeFile", "rb");
fread(&g_AIType, sizeof(AIType), 1, g_pFile);

[edited by - Spudder on February 6, 2004 7:33:47 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!