strerror

Maps the error number in error_code to a locale-dependent error message string.

Format

#include  <string.h>

char *strerror  (int error_code); 
                (ANSI C)

char *strerror  (int error_code[, int
                vms_error_code]); (DEC C Extension)

Arguments

error_code
An error code.
vms_error_code
An OpenVMS error code.

Description

This function uses the error number in error_code to retrieve the appropriate locale-dependent error message. The contents of the error message strings are determined by the LC_ MESSAGES category of the program's current locale.

When a program is not compiled with any standards-related feature- test macros (see Section 1.5.1), strerror has a second argument (vms_error_code), which is used in the following way:

See the strerror example.

Use of the second argument is not included in the ANSI C definition of strerror and is, therefore, not portable.

Because no return value is reserved to indicate an error, applications should set the value of errno to 0, call strerror, and then test the value of errno; a nonzero value indicates an error condition.

Return Values
A pointer to a buffer containing the appropriate error message. Do not modify this buffer in your programs. Moreover, calls to the strerror function may overwrite this buffer with a new message. 

Example

    #include <stdio.h>
    #include <errno.h>
    #include <string.h>
    #include <stdlib.h>
    #include <ssdef.h>
    
    main()
    {
        puts( strerror (EVMSERR) );
        errno = EVMSERR; vaxc$errno = SS$_LINKEXIT;
        puts( strerror (errno) );
        puts( strerror (EVMSERR, SS$_ABORT ) );
        exit(1);
    }
    

Running this example produces the following output:

non-translatable vms error code: <none>
network partner exited
abort


Previous Page | Next Page | Table of Contents | Index