Im using ifstream to read the content in text file.
But i want to ignore the first 5 line content.

what i do now is using the own function to ignore 1st 5 line content, then save it into new file and reopen the file again.
i think this is very waste time and also memory..any suggestion?
Thank you!

Why not
- read 5 lines
- do what you were going to do anyway

It doesn't need a temp file to do that.

oh,can use this method also.thx.
another question now...

how to reload the content inside the ifstream file. Below is a part of code i doing now..

ifstream infile("test.txt");
string line2;
while (!infile.eof())
	{
		getline(infile,line2);
		itotalCount++;
	}

Here is ok.i get the total line in that file.
But next when i need find another info in that file,
the while loop din't function.i think is because the previous line is already reach the eof..

while (!infile.eof())
{
   getline(infile,line2);

}

and i have try to use the infile.seekg(0);
but the content return from getline function is nothing.zz


So, have any ideal can reload the content? Or there is already got function in stl which i dunno?
I'm waiting your answer..Thank you!

Don't use EOF as an exit indicator for your loop, instead read a file like this:

while ( getline(infile, line2) )
{
   // Do stuff with the read data
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.