When I tried to read and extract each line from a .txt file,then copy these data to a buffer array,the get pointer reached the end of file and the eof() bit is set and the problem is no more read attemp from that file allowed.Please tell me how can I access the file again?I tried to clear the eof() bit but it didn't work.
And one more question: how can I delete some character from that .txt file without destroy its content?
Thanks in advance.
And one more question: how can I delete some character from that .txt file without destroy its content?
Don't understand the question. You can't really delete anything from a file but you can rewrite to the file or append to the file or write to a new file. What are you trying to do?
If you loop on eof() you won't be checking for fail() or bad(). Testing for good() or simply testing the stream as Duoas showed will fail in any of these cases.
std::ifstream ifs("my-file.txt");
ifs.clear(); // clear all error flags
ifs.seekg(0); // goto beginning of file.
If you want to delete a character from a text file then I suppose you will need to copy every character after the one you wish to delete back one. However, what are you trying to do? That sounds rather inefficient for most purposes.