strerror(errno) : strerror « string.h « C / ANSI-C






strerror(errno)



#include <stdio.h>
#include <string.h>
#include <errno.h>

int main ()
{
  FILE * pFile;
  pFile = fopen ("unexist.ent","r");
  if (pFile == NULL)
    printf ("Error opening file unexist.ent: %s\n",strerror(errno));
  return 0;
}

         
/*
Error opening file unexist.ent: No such file or directory (ENOENT)
*/ 
           
       








Related examples in the same category

1.strerror: returns error message associated with the errnum