you do not have to close and then reopen the file;
inData.clear() ; inData.seekg(0) ; is more efficient.
> I need the number of lines before I can correctly do the other stuff.
you do not; use a vector instead of a c-style array:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std ;
int main()
{
ifstream file( __FILE__ ) ;
string line ;
vector<string> lines ;
while( getline( file, line ) ) lines.push_back( line ) ;
cout << "#lines: " << lines.size() << '\n' ;
}
Last edited by vijayan121; Aug 16th, 2007 at 2:09 pm.
Reputation Points: 1159
Solved Threads: 285
Posting Virtuoso
Offline 1,606 posts
since Dec 2006