Jump to content
  • Advertisement

Archived

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

MetroidHunter

File reading question

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

Advertisement
You will gave to parse that one line.
Put your data on seperate lines instead or do it the "real" way; don''t save to textfile, instead save your struct.

Share this post


Link to post
Share on other sites
I think what you are looking for is fscanf.

Try starting on the Stream I/O page on MSDN.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_stream_i.2f.o.asp

Look for fscanf. You know when you use a printf and you want to format it as an int then a string then maybe a double and you go something like "%d, %s, %.2lf", someInt, someString, someFloat? Well fscanf will let you do the same thing but reading in from a file stream. So if you are reading in lines from a file you would open the file with fopen and then...

fscanf( stream, "%d %s %lf", &someInt, &someString, &someFloat );

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!