INtime SDK Help
strtol, wcstol

Converts a string to a long integer value.

#include <stdlib.h>

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

#include <wchar.h>

long wcstol(const wchar_t *nptr, wchar_t **endptr, int base);

Parameters

nptr
String to convert; a sequence of characters that can be interpreted as a numerical value of the specified type.
endptr
End of scan.
base
Number base to use.

Remarks

strtol expects nptr to point to a string with this form:

[whitespace][sign][0][{x|X}][digits]

These functions stop reading the string at the first character they cannot recognize as part of a number. This may be the null character \0 at the end of the string. With strtol or strtoul, this terminating character can also be the first numeric character greater than or equal to base. If endptr is not a null pointer, a pointer to the character that stopped the scan is stored at the location pointed to by endptr.

If no conversion can be performed (no valid digits are found or an invalid base is specified), the value of nptr is stored at the location pointed to by endptr.

Base Description
Between 2 and 36 Base used as the base of the number.
0 The initial characters of the string pointed to by nptr determine the base.
1st char = 0 and 2nd char not = x or X The string is interpreted as an octal integer; otherwise, it is interpreted as a decimal number.
1st char = 0 and 2nd char = x or X The string is interpreted as a hexadecimal integer.
1st char = 1 through 9 The string is interpreted as a decimal integer.
a through z or A through Z Are assigned the values 10 through 35; only letters whose assigned values are less than base are permitted.

strtoul allows a plus (+) or minus (-) sign prefix; a leading minus sign indicates that the return value is negated.

Return Values

strtol returns the value represented in the string nptr, except when the representation would cause an overflow, in which case it returns LONG_MAX or LONG_MIN. strtol returns 0 if no conversion can be performed.

wcstol returns values analogously to strtol. For both functions, errno is set to ERANGE if overflow or underflow occurs.

Generic Text Routines

tchar.h routine _UNICODE not defined _UNICODE defined
_tcstol strtol wcstol

Requirements

Versions Defined in Include Link to
INtime 3.0
INtime 6.0 (wide-character and generic text versions)
intime/rt/include/stdlib.h
intime/rt/include/wchar.h
intime/rt/include/tchar.h
stdlib.h
wchar.h
tchar.h
clib.lib
See Also