strtol [C++ Reference]
Keywords: c,string,strtol
Date: 2009-04-17T05:03:48-0700

[[strtol]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## strtol

Syntax:

        #include <cstdlib>
        long strtol( const char *start, char **end, int base );

The strtol() function returns whatever it encounters first in start as a long, doing the conversion to base if necessary. end is set to point to whatever is left in start after the long. If the result can not be represented by a long, then strtol() returns either LONG_MAX or LONG_MIN. Zero is returned upon error.

end can be NULL, but it is not recommended since testing whether end is different than start is the only way to tell an actual 0 to an error 0 (representing that no number was read at all). If LONG_MAX or LONG_MIN are returned, errno will be set to ERANGE.

Related Topics: atol, strtoul

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •