You are here : cpp0strerror

strerror() - 0

The C library function char *strerror(int errnum) searches an internal array for the error number errnum and returns a pointer to an error message string. The error strings produced by strerror depend on the developing platform and compiler.


Syntax

char *strerror(int errnum)


Example

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

int main ()
{
   FILE *fp;

   fp = fopen("file.txt","r");
   if( fp == NULL ) 
   {
      printf("Error: %s\n", strerror(errno));
   }
   
   return(0);
}


Output / Return Value

Error: No such file or directory


Limitations


Alternatives / See Also


Reference