<< fgetl | Stream manager | fileread >> |
res = fgets(f) |
res = fgets(f, n) |
a file descriptor
a scalar: number of characters
a string or -1
Read string from a file, stopping after a newline, or EOF, or n characters have been read.
If there is no more character to read, fgets will return -1.
If n is omitted, fgets reads until the next newline.
characters encoding uses fopen parameter.
fid = fopen([nelsonroot(), '/etc/startup.m']);
tline = fgets(fid);
while ischar(tline)
disp(tline)
tline = fgets(fid);
end
fclose(fid);
fid = fopen([nelsonroot(), '/etc/startup.m']);
tline = fgets(fid, 5);
while ischar(tline)
disp(tline)
tline = fgets(fid, 5);
end
fclose(fid);
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET