Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ strerror(DOS) — OpenDesktop Software Development System 1.0.0d

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     Name
          strerror - Gets error message pointer from last routine call
          error.

     Syntax
          #include <string.h>

          char *strerror(errnum)
          int errnum;

     Description
          The strerror routine maps errnum to an error-message string,
          returning a pointer to the string.  The function itself does
          not actually print the message; for that, you need to call
          an output function such as printf.

     Return Value
          The strerror function returns a pointer to the error-message
          string.  The string can be overwritten by subsequent calls
          to strerror.

     See Also
          clearerr(S), ferror(S), perror(S)

     Notes
          Under DOS and OS/2, some of the errno values listed in
          errno.h are not used.

     Example
          #include <string.h> #include <errno.h> #include <io.h>
          #include <fcntl.h> #include <sys/types.h> #include
          <sys/stat.h>

          extern int errno; int errnum; int fh1, fh2;

          main() {
                  errnum=0;
                  if ((fh1=open("xxxx",O_RDONLY)) == -1)
                          errnum=errno;
                  fh2=open("yyyy",O_RDONLY);

                  /* Other code that may set the errno value.*/
                  if (errnum != 0)
                  printf(strerror(errnum)); }

          The program shown above tries to open files xxxx and yyyy.
          If an error occurs opening xxxx, the variable errnum is set
          to the errno value returned by open.  Other code that may
          alter the errno value is then executed.  Later, the saved
          errno value in errnum is checked and, if nonzero, an error
          message assigned to it by strerror is printed.  If file xxxx
          does not exist, the example will print the following
          message:

                                No such file or directory

                                                (printed 6/18/89)



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