fgets - Read line from file, keeping newline character

Syntax

tline = fgets(fid)
tline = fgets(fid, nchar)

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 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 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, fread

  


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