I am sure people had this problem before and was wondering how people get around it. I use MyFile.ignore(100, '%') to get around the file where % is my marker (for example separating entries). In some cases when using this feature the pointer goes to -1, and I can't change it....in a way it gets 'jammed'. I know it's this because when I run:
Myfile.seekg(10); //puts pointer to 10 position
cout<<Myfile.tellg()<<endl;
Myfile.ignore(100, '%');
cout<<Myfile.tellg();
Output looks like this:
10
-1
when the pointer is at -1 I can't change it and the program gets messed up. Maybe it has something to do with .ignore function and loops? any suggestions? or is there an alternative to move around the file without using ignore?
Thanks in advance.
Myfile.seekg(10); //puts pointer to 10 position
cout<<Myfile.tellg()<<endl;
Myfile.ignore(100, '%');
cout<<Myfile.tellg();
Output looks like this:
10
-1
when the pointer is at -1 I can't change it and the program gets messed up. Maybe it has something to do with .ignore function and loops? any suggestions? or is there an alternative to move around the file without using ignore?
Thanks in advance.