|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
#include <stdlib.h> long strtol(const char *s, char **endp, int base);
This function converts as much of s as looks like an appropriate number into the value of that number. If endp is not a null pointer, *endp is set to point to the first unused character.
The base argument indicates what base the digits (or letters)
should be treated as. If base is zero, the base is determined by
0 as the first part of the
string, and sets the base used to 16, 16, or 8 if it finds one. The
default base is 10 if none of those prefixes are found.
|ANSI/ISO C||C89; C99|
printf("Enter a number: "); fflush(stdout); gets(buf); char *bp; printf("The value is %d\n", strtol(buf, &bp, 0));
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2004 by DJ Delorie||Updated Apr 2004|