Older Newer
Thu, 26 Dec 2019 14:14:23 . . . . SyneRyder [Fix typos]


Changes by last author:

Added:
= strtol =

== Syntax ==

:long strtol(const char* nptr, char** endptr, int base)

== Arguments ==

:nptr

::Pointer to the string containing the value to convert.

:endptr

::Optional storage space for output by this function.

:base

::The numerical base of the number, anything from 2 up to and including 36 or zero.

== Return ==

:The converted value from the string.

== Description ==

:This function will convert a string to a long value.

:The string is expected to have optional leading white space followed by an optional plus (+) or minus (-) character and any number of digits.

:If base is set to 16 (hexadecimal), the string may begin with an optional '0x' prefix.

:If base is set to 0, the string will be parsed as having base 10 (decimal) unless it starts with '0x', in which case is is parsed as having base 16 (hexadecimal), or '0', in which case it is parsed as having base 8 (octal). This allows this function to parse C-style numbers.

:If endptr is not NULL, a pointer to the next character after the parsed portion of the string is stored in the memory location reference by endptr.

:If the resultant value would overflow the boundaries of the long datatype, the maximum possible value is returned. If an underflow would occur, zero will be returned. In both cases an errorcode will be set which can be queried.

== See Also ==

:strtod, strtoul

== Comments ==

:Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.