On Mon, Jul 9, 2012 at 4:01 AM, Peter Newman
<address@hidden> wrote:
I simplified the code to show the essence of the problem.
Here is the code that should skip an empty line...
1;
fid=fopen("emptyline.txt");
l = fgetl (fid);
while (l~=(-1))
if ~isempty(l)
printf("%s\n", l);
endif
l = fgetl (fid);
end
Here is the file contents of "emptyline.txt"
0010
0020
0030
0040
Why does the while loop exit on an empty line?
See the result of:
'' ~= -1
'abcde' ~= -1
and you'll understand why your loop stops at the first empty line (your loop test does a element-wise vector comparison; with an empty string, the result is an empty matrix ([]) and this is equivalent to false).
Michael.