fgetl - Read line from file, discarding newline character

Syntax

tline = fgetl(fid)

Description

tline = fgetl(fid) returns the next line of the file associated with the file identifier fid. If fgetl encounters the end-of-file indicator, it returns -1. (See fopen for a complete description of fid.) fgetl is intended for use with files that contain newline characters.

The MATLAB® software reads characters using the encoding scheme associated with the file. See fopen for more information.

The returned string tline does not include the line terminator(s) with the text line. To obtain the line terminators, use fgets.

Examples

The example reads every line of the M-file fgetl.m.

fid=fopen('fgetl.m');
while 1
    tline = fgetl(fid);
    if ~ischar(tline),   break,   end
    disp(tline)
end
fclose(fid);

See Also

fgets, fread

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS