strerror - C string.h

C examples for string.h:strerror

Type

function

From

<cstring> 
<string.h>

Description

Interprets the value of errnum, generating a string that describes the error condition.

Prototype

char * strerror ( int errnum );

Parameters

Parameter Description
errnum Error number.

Return Value

A pointer to the error string describing error errnum.

Demo Code


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

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

Related Tutorials