help-octave
[Top][All Lists]
Advanced

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

getl strange behaviour (?)


From: talassio
Subject: getl strange behaviour (?)
Date: Wed, 16 Jul 2008 20:07:54 -0700 (PDT)

Hello!

Suppose we want to getl the following file: fid=fopen(pfmc100.dimacs, "r");
 --- start file ---
a 5    4  0    5 -1
a 6    5  0    8  0
a 6    4  0   15  7
 --- end file ---

> linea = getl(fid);
> [str de a l u c cnt] = sscanf(linea, '%s %i %i %i %i %i', "C");
c = -1
cnt = 6

> linea = getl(fid);
> [str de a l u c cnt] = sscanf(linea, '%s %i %i %i %i %i', "C");
c = [](0x0)
cnt = 5

> linea = getl(fid);
> [str de a l u c cnt] = sscanf(linea, '%s %i %i %i %i %i', "C");
c = 7
cnt = 6

That is, if the last number on a line is 0 (zero) it won't be correctly
read: c=[](0x0) with cnt=5. If it is other number/letter there is no problem
(cnt=6).

A work around is:

> [str de a l u c cnt] = sscanf(linea, '%s %i %i %i %i %s', "C");
c = str2num(c)

and worked as expected on the lines where the last item is a 0 (zero).

I am not sure this is the correct behaviour of getl(...).

Any comments?

Andres.


-- 
View this message in context: 
http://www.nabble.com/getl-strange-behaviour-%28-%29-tp18500752p18500752.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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