0

I'm working on a simple program to analyse some data and I'm having trouble making multiple passes over my file. I've been trying to do something along the lines of

for(n=0;n<Nmax;n++){
                      while (! inFile.eof() ){
                            crap done here;
                      };   
    };

however it won't do more than one pass over the file. Is there a way I can make it pass over the file multiple times like this?

Edited by mike_2000_17: Fixed formatting

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by dalj
0

see,
after first pass of for look, file reading pointer will be at the end. so during next for loop passes it wont go inside while loop as (! inFile.eof() ) will be false.
You have to reset the file reading pointer to start of the file before while loop.

0

Ok, I got it working. I ended up inserting:

inFile.clear() ;
inFile.seekg( 0, std::ios::beg );

Thanks for the help.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.