Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(2)



  perror(3)                           CLIX                           perror(3)



  NAME

    perror, errno, sys_errlist, sys_nerr - Provides system error messages

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    void perror(
      char *s ,
      extern int errno ,
      extern char *sys_errlist[] ,
      extern int sys_nerr );

  PARAMETERS

    s   Specifies a message string.

  DESCRIPTION

    The perror() function produces a message on stderr.  describing the last
    error encountered during a call to a system or library function.  The
    argument string s is displayed first, then a colon and a blank, then the
    message and a newline.  (However, if s="" the colon is not displayed.)  To
    be of most use, the argument string should include the name of the program
    that incurred the error.  The error number is taken from the external
    variable errno, which is set when errors occur but not cleared when
    nonerroneous calls are made.

    To simplify variant formatting of messages, the array of message strings
    sys_errlist is provided; errno can be used as an index into this table to
    get the message string without the newline.  The value of sys_nerr is the
    number of messages in the table; it should be checked because new error
    codes may be added to the system before they are added to the table.

  EXAMPLES

    1.  To list the messages associated with their error numbers:

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

        main()
        {
             extern char *sys_errlist[];
             extern int sys_nerr, errno;
             for(errno=0;errno<sys_nerr;errno++)
                  printf("Error %d: %s.\n",errno,sys_errlist[errno]);




  2/94 - Intergraph Corporation                                              1






  perror(3)                           CLIX                           perror(3)



        }



    2.  To list all of the error messages in sys_errlist using perror():

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

        main()
        {
             extern char *sys_errlist[];
             extern int sys_nerr, errno;
             for(errno=0;errno<sys_nerr;errno++)
                  perror("Error ");
        }


    Note the perror() function does not display the value of errno.

  RETURN VALUES

    The perror() function returns no value.

  RELATED INFORMATION

    Functions:  intro(2)



























  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026