ferror
Test for i/o read/write errors.
📝Syntax
msg = ferror(fid)
[msg, code] = ferror(fid)
ferror(fid, 'clear')
📥Input Arguments
Parameter Description
fid a file descriptor
📤Output Arguments
Parameter Description
code an integer value: 0 if no error. negative value if an error is detected.
msg an character vector: error message equivalent to error code.
📄Description

ferror inquires about file error status.

ferror(fid, 'clear') clears the error indicator for the specified file.

For more help about returned message, consult C run-time library manual for further details.

💡Examples
filename = [tempdir(), 'test_ferror.csv'];
fid = fopen(filename, 'w');
res = fgets(fid);
[msg, code] = ferror(fid)
🔗See Also
fopen
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub