MATLAB Function Reference    
fgets

Read line from file, keep newline character

Syntax

Description

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

The returned string tline includes the line terminators associated with the text line. To obtain the string without the line terminators, use fgetl.

tline = fgets(fid,nchar) returns at most nchar characters of the next line. No additional characters are read after the line terminators or an end-of-file.

See Also

fgetl


  fgetl (serial) fgets (serial)