strtoul
unsigned long strtoul ( const char * string, char** endptr, int radix ); | stdlib.h |
cplusplus.com |
Convert string to unsigned long integer.
Parses string interpreting its content as an integer value until a character
that can not be interpreted is found,
and returns an unsigned long value.
Parameters.
initial chars Interpreted by strol as 0x hexadecimal: radix 16 0 octal: radix 8 any number from 1 to 9 decimal: radix 10
Return Value.
The converted unsigned long value from the input string.
If conversion would cause overflow the result is ULONG_MAX.
If an error occurs or no conversion can be made 0 is returned.
Portability.
Defined in ANSI-C.
Example.
/* strtoul example */
#include <stdio.h>
#include <stdlib.h>
main ()
{
char szInput [256];
char * pEnd;
unsigned long ul;
printf ("Enter an integer value: ");
gets (szInput);
ul = strtoul (szInput,&pEnd,0);
printf ("Value entered: %lu. Its double: %lu\n",ul,ul*2);
return 0;
}
See also.
atof,
strtol,
strtoul