ferror

Purpose

Query MATLAB about errors in file input or output.

Synopsis

message = ferror(fid)
message = ferror(fid,'clear')
[message, errnum] = ferror(...)

Description

message = ferror(fid) returns the error message message. fid is a file identifier associated with an open file. (See fopen for a complete description of fid.)

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

[message, errnum] = ferror(...) returns the error status number errnum of the most recent file I/O operation associated with the specified file.

If the most recent I/O operation performed on the specified file was successful, ferror returns an errnum value of 0 and the value of message is empty.

A nonzero errnum indicates an error occurred in the most recent file I/O operation. Two ways that you can learn more about the nature of the error are

  • The value of message is a string that may contain information about the nature of the error.
  • If you have access to a C language reference manual, you can look at the error codes generated by file I/O operations provided by the C language library stdio.

    See Also

    fclose, fopen, fprintf, fread, fscanf, fseek, ftell, fwrite, sprintf, 
    sscanf
    

    (c) Copyright 1994 by The MathWorks, Inc.