feof(), ferror(), perror() Functions in C - C-Tutorial

Latest

Thursday, 10 November 2016

feof(), ferror(), perror() Functions in C



 feof() Function:
           
            feof() is a library used to test for end-of-file condition.  The general format of feof() function is:

            Syntax             :           feof(FilePointer)

            Function accepts FilePointer as its only argument and returns a non-zero integer value if EOF reached; otherwise, it returns zero.

 ferror() Function:

            ferror() is a library function used to report error status of the file indication.  The general format of ferror() function is:

            Syntax:            ferror(FilePointer)

Function accepts FilePointer as its only argument and returns a non-zero integer value if an error has been detected up to that point during processing; otherwise, it returns zero.

  perror() Function:

            perror() is a standard library function used to print error messages specified by the compiler.

            With this function, whenever an error occurred; the function prints error message to stderr.

The general format of perror() function is:

Syntax             :           perror(“string”);


Here, First the argument string is printed, then a colon, then a message corresponding to the current value of error, finally a new line.

No comments:

Post a Comment