Jump to content
  • Advertisement

Archived

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

hello_there

please help me!!

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

ok i can load number from a file into an array by loading every number seperatly. is there a way to load the whole thing in a few lines of code? i hope that makes sence

Share this post


Link to post
Share on other sites
Advertisement
Okay, if you know how to use for loops, and you know how to read one number using ifstream, then you''re all set.

Open your file like you did before, I''m assuming the ifstream object is called f, then do something like...


  
int i;
int n[10];

for (i = 0; i < 10; i++)
{
f >> n[i];
}


This doesn''t do any error checking, but you should. Also, you really have to buy a book on C++. Or use google.

- Pete

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!