help-octave
[Top][All Lists]
Advanced

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

Re: fgets difference octave to c


From: Uwe Damm
Subject: Re: fgets difference octave to c
Date: Fri, 22 Feb 2019 19:30:13 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

you saved my weekend:-)

fclear(fd) did the job!

Uwe


Am 22.02.19 um 18:58 schrieb "Markus Mützel":
On 22 Feb 2019 06:28:44 -0600 (CST) "uwedamm" wrote:
I try to read data from a text-file using fopen/fgets, which is written in
some other process.
If I do that in c, data, which is written by the other process can be read:
while(1)
{
     if(fgets(buf,100,fp))
         printf("%s\n",buf);
}

If I do that in octave, only data which was written before starting the
octave script is read, after that no new data is available and the fgets
continuously returns -1:
while (1)
     ln=fgets(fd,100);
     if(ln ~= -1)
         disp(ln);
         fflush(stdout);
     end
end

How can I proceed to continuously read data from the other process (like
e.g. in tail)?
I am not sure whether this will help, but you could try calling fclear(fd) 
after each time you reached eof. This should essentially call ios::clear on the 
stream:
http://www.cplusplus.com/reference/ios/ios/clear/

Markus




reply via email to

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