Repeated use of io:fread fails

Roger Price rprice@REDACTED
Fri Oct 25 11:38:56 CEST 2002


I placed three integers into a file

   echo " 7 11 13" > /tmp/test

and then tried to read the first two with the program

f(File) -> {ok,Stream}=file:open(File,read),
           X=io:fread(Stream,'',"~d"),
           %% ...a comment...
           Y=io:fread(Stream,'',"~d"),
           file:close(Stream),
           io:format("X=~p.  Y=~p.~n", [X,Y]) .

but the result is

23> f("/tmp/test") .
X={ok,[7]}.  Y={error,fread}.
ok

I compiled with option 'native' using Erlang version R8B-1, hipe enabled.

Is it illegal to make consecutive calls to io:fread?

Best Regards,
Roger




More information about the erlang-questions mailing list