FUNCTION REFERENCE

fgetl

Read one line of a file without the line break.

Read one line of a file without the line break.

Syntax

tline = fgetl(fid)

Syntax

tline = fgetl(fid, nchar)

Syntax

[tline, ltout] = fgetl(fid)

Returns -1 when there is nothing left to read, and an empty character array for

a file opened only for writing. An empty line gives an empty character array.

A line ends at LF, CR LF or a lone CR. The terminator is removed and returned

as ltout. Both fgetl and fgets skip a leading UTF-8 BOM in text mode ('rt').

Example

fid = fopen('data.txt'); l = fgetl(fid)   % '1,3'

Differences from MATLAB: bytes that are not valid UTF-8 are read one character

per byte.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.