[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fgets differ in C and octave?

From: Andreas Weber
Subject: Re: fgets differ in C and octave?
Date: Fri, 22 Feb 2019 17:32:30 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

Am 22.02.19 um 17:23 schrieb Andreas Weber:
Am 22.02.19 um 14:26 schrieb uwedamm:
If the last line was read, fgets only reports "-1", even if new data is
written to the file by the other process.

I believe what you see, is that fgets geturns -1 as soon as there is no more data to read. If you've encountered this condition, you have to clear the error state with "fclear(fid)"

A more complete example:

Open a shell and run
ping >

then in GNU Octave:

fid = fopen ("", "r");
if (fid < 0)
  error ("no found...")


  while (1)

    f = fgetl (fid)

    if (f < 0)
      pause (0.2);
      fclear (fid)


  fclose (fid)


HTH, Andy

reply via email to

[Prev in Thread] Current Thread [Next in Thread]