MATLAB Function Reference | ![]() ![]() |
Read line from file, discard newline character
Syntax
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 text files only.
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
![]() | fftshift | fgetl (serial) | ![]() |