please help me!!

Started by
5 comments, last by hello_there 22 years, 1 month ago
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
____________________________________________________________How could hell be worse?
Advertisement
What kind of number, and is it a binary or ascii file?
ascii file and the numbers are integers and i programme in c++.
____________________________________________________________How could hell be worse?
Are you using C++ iostream or FILE *?
put it in a loop.

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
iostream
____________________________________________________________How could hell be worse?
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

This topic is closed to new replies.

Advertisement