Displaying Errno - HP 9000 Series 300 Tutorials Manual

Device i/o and user interfacing hp-ux concepts and tutorials
Hide thumbs Also See for HP 9000 Series 300:
Table of Contents

Advertisement

Displaying errno
Once errno has been declared in a program, there are two ways to check its
value if a routine fails. The simplest approach is to check the return value to
determine whether or not the routine failed, then print out the value of errno
and exit if it did. The following example illustrates this strategy:
#include <errno.h>
#include <fcntl.h>
mainO
{
}
int eid;
if «eid
=
open(II/dev/raw_hpib
ll
,
O_RDWR»
==
-1)
{
}
printf("Error occurred. Errno
=
%d", errno);
exit(1);
When this method is used, the program user must refer to the errno(2) entry
in the HP- UX Reference to determine what the printed value of errno means.
General-Purpose Routines
2-11

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Hp 9000 series 800

Table of Contents