

strtol()                 General Function                strtol()




Convert string to long integer

#iinncclluuddee <ssttddlliibb.hh>
lloonngg ssttrrttooll(_s_t_r_i_n_g, _t_a_i_l_p_t_r, _b_a_s_e)
char *_s_t_r_i_n_g; cchhaarr **_t_a_i_l_p_t_r; iinntt _b_a_s_e;

ssttrrttooll converts the number given  in _s_t_r_i_n_g to a lloonngg and returns
its value;  it is  a more general  version of the  function aattooll.
ssttrrttooll also stores a pointer to the first character following the
number through _t_a_i_l_p_t_r, provided _t_a_i_l_p_t_r is not NNUULLLL.

_b_a_s_e gives the base of the number being read, either 0 or a value
from 2  to 36.  If the  given _b_a_s_e is zero,  ssttrrttooll determines an
implicit base  for the number:  hexadecimal if the  number starts
with  00xx  or 00XX, octal  if the number  starts with 00,  or decimal
otherwise.  Alternatively,  you can specify a  _b_a_s_e between 2 and
36.

ssttrrttooll  parses  _s_t_r_i_n_g into  three  portions: beginning,  subject
sequence, and tail.

The  _b_e_g_i_n_n_i_n_g consists  of zero  or more  white-space characters
that begin the string.

The _s_u_b_j_e_c_t  _s_e_q_u_e_n_c_e is  the portion  of the string  that ssttrrttooll
converts into a lloonngg.  It consists of an optional sign character,
an optional  prefix 00xx or  00XX if the  _b_a_s_e is 16,  and a nonempty
sequence of  _d_i_g_i_t_s in the  specified base.  For  example, if the
_b_a_s_e is 16, then  ssttrrttooll recognizes numeric characters `0' to `9'
and  alphabetic characters  `A'  through `F'  and `a'  to `f'  as
digits.  It continues to scan until it encounters a nondigit.

The _t_a_i_l  continues from the  end of the subject  sequence to the
null character that ends the string.

ssttrrttooll ignores the  beginning portion of the string.  It converts
the subject sequence to a  lloonngg. Finally, if _t_a_i_l_p_t_r is not NNUULLLL,
it sets the  pointer pointed to by _t_a_i_l_p_t_r to  the address of the
first character of the string's tail.

ssttrrttooll  returns a  lloonngg  representing the  value  of the  subject
sequence.  If  the input _s_t_r_i_n_g does not  specify a valid number,
it returns  zero and stores  the initial value  of _s_t_r_i_n_g through
_t_a_i_l_p_t_r. If the number it builds is too large or too small to fit
into a  lloonngg, it sets the  global variable eerrrrnnoo to  the value of
the macro EERRAANNGGEE and returns LLOONNGG_MMAAXX or LLOONNGG_MMIINN, respectively.

***** See Also *****

aattooll, eerrrrnnoo, ggeenneerraall ffuunnccttiioonnss, lliimmiittss.hh, lloonngg, ssttddlliibb.hh, ssttrrttoouull

***** Notes *****

ssttrrttooll  ignores initial  white space in  the input  _s_t_r_i_n_g. White


COHERENT Lexicon                                           Page 1




strtol()                 General Function                strtol()



space is  defined as  being all  characters so recognized  by the
function iissssppaaccee.























































COHERENT Lexicon                                           Page 2


