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: Markus Mützel
Subject: Re: fgets difference octave to c
Date: Fri, 22 Feb 2019 18:58:49 +0100

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]