I need to read from a file line by line, it's done by std::getline. The problem another process is appending data to it all the time, then I need to read the new lines.
For example, the file contains 10 lines at first, my program read the 10 line, then my program should wait. A while later another process append 5 lines to the file, then my program read the 5 lines.
I tried this but it doesn't work:
int main() {
ifstream ifs("test.txt");
string line;
while(1) {
while(std::getline(ifs, line)) {
cout << line << endl;
}
Sleep(50);
}
}
Any idea? Thanks.