VMS Help  —  CRTL  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)

1  –  Arguments

 error_code

    An error code.

 vms_error_code

    An OpenVMS error code.

2  –  Description

    The strerror 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, strerror has a second argument (vms_error_
    code), which is used in the following way:

    o  If error_code is EVMSERR and there is a second argument, then
       that second argument is used as the vaxc$errno value.

    o  If error_code is EVMSERR and there is no second argument, look
       at vaxc$errno to get the OpenVMS error condition.

    See the Example section.

    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.

3  –  Return Value

    x                  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.

4  –  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:

    nontranslatable vms error code: <none>
    network partner exited
    abort
Close Help