Hello.
I make code whose get count line but not reset position in file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// ifstream file;
int MyClass::count(){
int i=0;
int pS = file.tellg();
file.seekg(0);
while (!file.eof()){
// my function get line, it work good
i++;
}
// cannt not set file to position pS
file.seekg(pS);
return i;
}
EDIT THIS POST!!!
Sorry, I find answer:
I must use method clear(); before seekg();