Reputation: 242
I'm fairly perturbed that the below does not appear to work.
while(myfile.good())
{
myfile.get(holdc);
....................
}
//does not work
myfile.seekg(0);
myfile.read(buffer,5);
sentence.push_back(buffer);
cout << buffer<<endl;
delete[] buffer;
I have tried myfile.close, etc., even creating a new ifstream myfile2;
to reload the file. Nothing works. It's as if this seekg thing is universal or something, and works only once per program.
Upvotes: 0
Views: 228
Reputation: 242
it appears, right after
while(myfile.good())
{
myfile.get(holdc);
....................
}
I need to do
myfile.clear();
However, I still need to know how to go ahead through the new line and read form file. After the first line ends I get random symbols. Anyone?
edit**
What happened was I used a dynamic array char buffer, which needs to be closed with:
buffer[i] = 0;
Upvotes: 0