[Previous]
[Contents]
[Next]

strerror()

map an error number to an error message

Synopsis:

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

Description:

The strerror() function maps the error number contained in errnum to an error message. The messages for this function are listed in the appendix on Implementation-Defined Behavior.

Returns:

A pointer to the error message. Don't modify this array; it may be overwritten by a subsequent call to the strerror() function.

Examples:

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

void main()
  {
    FILE *fp;

    fp = fopen( "file.nam", "r" );
    if( fp == NULL ) {
      printf( "Unable to open file: %s\n",
         strerror( errno ) );
    }
  }

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

clearerr(), feof(), ferror(), perror()


[Previous]
[Contents]
[Next]