1 Temmuz 2019 Pazartesi

clearerr metodu

Giriş
Açıklaması şöyle
There is at least one real world use case for clearerr: when you want to mimic tail -f on a file that is not opened in exclusive mode. That means that another (or many other) process(es) write at the end of a file, and one process repeatedly reads even after having reached the end of file in order to look whether new data has arrived.
Örnek
Şöyle yaparız
for (;;) {
  if (NULL == fgets(line, sizeof(line), fd)) {
    sleep(n);
    clearerr(fd);     // reset EOF condition
  }
  else {
    fputs(line, fdout);
  }
}

Hiç yorum yok:

Yorum Gönder