Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - strtol http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                                  strtol

   Usage
   #include <stdlib.h>
   long strtol(char *nptr,char **endptr,int base);

   Description
   strtol converts the ASCII string pointed to by nptr to a long integer-
   value. It will recognize white space then an optionally signed  string
   of digits. It will stop reading the string at the first character that
   doesn't  represent a part of the number. A pointer to  that  character
   will be stored in the object endptr if endptr is not NULL.

   If  base  is  zero the first character after the  optional  sign  will
   determine the base of the conversion. If the first character is 0  and
   the second character is not `x' or `X', then the string is interpreted
   as octal. If the first character is 0 and the second character is  'x'
   or 'X' it will be interpreted as a hexadecimal integer.

   If  the  first  character is '1' - '9' the string  is  interpreted  as
   decimal  integer. The upper or lower case letters A - Z  are  assigned
   the values from 10 through 35. Only letters with values less than  the
   base  are permitted. If the base is not 0, the base must be between  2
   and 36.

   Example
   see strtoul

   Return Value
   If correct values would cause an overflow then LONG_MAX or LONG_MIN is
   returned  according  to  the sign and errno is set to  ERANGE.  If  an
   unrecognized  character is encountered before a legal character,  zero
   is returned.


See Also: atoi atol strtoul scanf

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson