Implement “tail -f” in C++

后端 未结 6 594
灰色年华
灰色年华 2020-12-10 03:47

I want to create a small code in C++ with the same functionality as \"tail-f\": watch for new lines in a text file and show them in the standard output.

The idea is

6条回答
  •  天命终不由人
    2020-12-10 04:01

    Just keep reading the file. If the read fails, do nothing. There's no need to repeatedly open and close it. However, you will find it much more efficient to use operating system specific features to monitor the file, should your OS provide them.

提交回复
热议问题