
------------------------------------------------------------------------------
7.3 Convert string to long value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strtol
[Syntax]
#include <stdlib.h>
long strtol( const char *nptr, char **endptr, int base ) ;
[Arguments]
nptr Pointer to a string.
endptr Pointer which points the position where reading is
stopped.
base Base number.
[Return]
Returns a converted value of long type. If overflow, returns
LONG_MAX or LONG_MIN and sets ERANGE in a global variable "errno".
[Description]
Converts a string pointed by "nptr" to long integer value using
"base" as a base number of conversion.
Format of strings is as follows.
(whitespaces)(+,-)(0)(x,X)(numeric_characters)
A pointer which points the position where reading is stopped is
stored in "endptr". If "endptr" is NULL, nothing is stored. If a
base number is between 2 and 36, conversion is performed using it.
If a base number is zero, the top characters decide a base number as
follows.
if (0)+(0 - 7) then octal
else if (0)+(x or X) then hexadecimal
else if (1 - 9) then decimal