Need help - looping through a text file

Hey guys I'm trying to read in data from a text file using a loop. The text file has 2 types of data - a bank account id and the balance for each account.

We had to define a class (with constructors, setters/getters, and destructors) and now I'm at the end of the assignment. How would I read the data for each account from the file, then create an object with the Class that I defined to use that data. I want to store the object in an array.

Thanks!
I can't help you with the class and object thing, but to 'loop' thru a data file it should be as simple
as
1
2
3
4
5
6
For (...)
     filename >> ID[index];
     filename >> Bal[index];
    // or
    filename >> results [index][1];
    filename >> results [index][2];

That should assemble a matrix of given proportions to stroe the information in the file and in the for loop , if you know the end line number you could loop like to or use
while (!filename.eof()), [ I think that's the correct format] but this will constantly check for the end of file character and stop your file reading when you hit that character.
Topic archived. No new replies allowed.