The errno.h header file provides the global error code variable errno.
This function is compatible with the following targets:
|
|
#include <errno.h>
extern int errno;
WARNING!
Most functions in the standard library return a special value when an error occurs. Often the programmer needs to know about the nature of the error. Some functions provide detailed error information by assigning a value to the global variable errno. The errno variable is declared in the errno.h header file. See "Error number definitions,"
The errno variable is not cleared when a function call is successful; its value is changed only when a function that uses errno returns its own error value. It is the programmer's responsibility to assign 0 to errno before calling a function that uses it. For example usage see Listing 8.1
|
errno value
|
Description
|
|
Win32 Only
|
Description
|
|
BeOS Only
|
Description
|
|
If _POSIX Defined
|
Description
|
#include <errno.h>
#include <stdio.h>
#include <extras.h>
int main(void)
{
char *num = "5000000000";
long result;
result = strtol( num, 0, 10);
if (errno == ERANGE)
printf("Range error!\n");
else
printf("The string as a long is %ld", result);
return 0;
}
/* Output:
Range error!
*/
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000