So how do I get an ifstream object to start at the top of the file again, if its already read some lines with getline() and/or is already at the end of the file?
I'm using the global getline() function which has a prototype of the following:
I tried calling ios::clear() before the getline call, but it didn't work. The ifstream object is still at the end of the file after the call to ifstream_object_name.clear().Code:istream& getline ( istream& is, string& str );
After attempting that, and it not working, I went and looked at the reference to ios::clear(), and learned it only clears the error flags. It doesn't reset the input filestream to the top of the file, unfortunately. So how do I do that?



LinkBack URL
About LinkBacks





penFile() after each call to C_script_operations::findScriptTag() and then to C_script_operations::findJsFunctionNames(), and then proceed to call C_script_operations::findHtmlElementsWithJsFunctio nCall(), and I didn't want to do that, due to the nature of my loop in int main(). I would have had to change some things, I think. So rather than rewrite code I had already written, I opted to find the better solution of starting the second ifstream object (input_stream2) at the top of the file again, if input_stream2.eof() returned true at the top of the function findHtmlElementsWithJsFunctionCall().