td211
td211

Reputation: 158

How to refresh an input file stream in C++

I am writing a program that monitors for changes in a file for a specific purpose. The possible values (3) in the file are known and can be differentiated by the first letter. Using an input file stream ifstream status;, I'm unable to refresh the buffer of the input stream status to reflect changes in the file. I don't want to spam status.close() and status.open() to solve the problem.

Upvotes: 0

Views: 828

Answers (1)

Caglayan Dokme
Caglayan Dokme

Reputation: 1138

If the changes you mentioned include only appended bytes, then you can use the std::ifstream::clear() to clear any error bit and continue reading the file until reaching the EOF. Check out this answer.

Upvotes: 1

Related Questions