Documentation

ferror

File I/O error information

Syntax

message = ferror(fileID)
[message,errnum] = ferror(fileID)
[message,errnum] = ferror(fileID,'clear')

Description

message= ferror(fileID)returns the error message for the most recent file I/O operation on the specified file.

[message,errnum] = ferror(fileID)returns the error number that is associated with the error message.

[message,errnum] = ferror(fileID,'clear')clears the error indicator for the specified file. Specify the literalclearas a character vector or a string scalar. When you clear the error indicator, succeeding calls toferrorbehave as if the most recent I/O operation is successful.

Input Arguments

collapse all

File identifier of an open file, specified as an integer.fileIDcan be one of these values:

  • N— Input or output from a file with a valid file identifier generated by thefopenfunction.Nis equal to or greater than3.

  • 0— Input from a standard input device.

  • 1— Output to a standard output device.

  • 2— Standard error.

Data Types:double

Output Arguments

collapse all

Error message, returned as character vector containing the error message associated with the most recent I/O operation. If the most recent I/O operation is successful or if you clear it manually, thenmessageis an empty character vector.

Error number, returned as an integer code associated with the error from most recent file I/O operation. If the most recent file I/O operation is successful, thenerrnumis0. A nonzeroerrnumindicates an error:

  • Negative values correspond to MATLAB®error messages.

  • Positive values correspond to C library error messages for your system.

Introduced before R2006a

Was this topic helpful?