C strerror function

« Previous

Synopsis:

Example

#include <stdio.h>
#include <errno.h>
char *strerror(int  errnum );

Description:

The strerror() function returns a string describing the error code passed in the argument errnum. Here passed value will be errno

Return Value

The strerror() function returns the appropriate error description string, or an unknown error message if the error code is unknown. The value of errno is not changed for a successful call, and is set to a nonzero value upon error.

Example

Example

#include <stdio.h>
#include <errno.h>
extern int errno ;
int main ()
{
  FILE * pFile;
  pFile = fopen ("unexist.ent","rb");
  if (pFile == NULL)
  {
    printf( "Error Value is : %s\n", strerror(errno) );
  }
  else
    fclose (pFile);
  return 0;
}

If file unexist.ent does not exit then it will produce following Output Will Be :

Example

Error Value is : No such file or directory


« Previous
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!