COHERENT manpages
This page displays the COHERENT manpage for strtol() [Convert string to long integer].
List of available manpages
Index
strtol() -- General Function (libc) Convert string to long integer #include <stdlib.h> long strtol(string, tailptr, base) char *string; char **tailptr; int base; strtol() converts the number given in string to a long and returns its value; it is a more general version of the function atol(). strtol() also stores a pointer to the first character following the number through tailptr, provided tailptr does not equal NULL. base gives the base of the number being read, either zero or a value from two to 36. If the given base is zero, strtol() determines an implicit base for the number: hexadecimal if the number starts with 0x or 0X, octal if the number starts with 0, or decimal otherwise. Alternatively, you can specify a base between 2 and 36. strtol() parses string into three portions: beginning, subject sequence, and tail. The beginning consists of zero or more white-space characters that begin the string. The subject sequence is the portion of the string that strtol() converts into a long. It consists of an optional sign character, an optional prefix 0x or 0X if the base is 16, and a nonempty sequence of digits in the specified base. For example, if the base is 16, then strtol() 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 tail continues from the end of the subject sequence to the null character that ends the string. strtol() ignores the beginning portion of the string. It converts the subject sequence to a long. Finally, if tailptr is not NULL, it sets the pointer pointed to by tailptr to the address of the first character of the string's tail. strtol() returns a long representing the value of the subject sequence. If the input string does not specify a valid number, it returns zero and stores the initial value of string through tailptr. If the number it builds is too large or too small to fit into a long, it sets the global variable errno to the value of the macro ERANGE and returns LONG_MAX or LONG_MIN, respectively. See Also libc ANSI Standard, §7.10.1.5 Notes strtol() ignores initial white space in the input string. White space is defined as being all characters so recognized by the function isspace().