Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>strtoul() convert string to unsigned long</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strtoul()               Convert String to Unsigned Long

 #include   <stdlib.h>

  unsigned long int strtoul(num_ptr, end_ptr, base);
  const char *num_ptr;   String to convert
  char **end_ptr;        Pointer to last character read
  int base;                   Number base to use

    strtoul() converts a character string to an unsigned long integer
    value.  The input string is a sequence of characters that can be
    interpreted as a numerical value of the specified type.

    strtoul() stops reading at the first character it cannot recognize as
    part of a number, which will typically be the terminating null
    ('\0'), but can also be the first numeric character greater than
    base. If end_ptr is not the null character, it points to the
    character that stopped the scan.

    Returns:    The converted value, if any. If no conversion can be
                performed, strtoul() returns 0. It returns ULONG_MAX on
                overflow. If overflow or underflow occurs then errno is
                set to ERANGE.

      Notes:    num_ptr must have the form:

 [optional whitespace] [optional 0] [optional x or X] [digits and letters]

                If base is between 2 and 36, then it is used as the base
                of the number.  If base is 0, the initial characters of
                num_ptr are used to determine the base:

                    1st character    Next character    Base
                    -------------    --------------    ----------------
                         0               0 - 7          Octal integer
                         0               x or X         Hex integer
                       1 - 9             1 - 9          Decimal integer

                The letters from 'a' to 'z' (or 'A' to 'Z') are assigned
                the values 10 - 35; only letters whose assigned values
                are less than base are permitted.

   Portability:     ANSI

 -------------------------------- Example ---------------------------------

 This program prints the unsigned long hexadecimal value of "89ABCDEF"

           #include <stdlib.h>

           main()
           {
              char *end_ptr;

              printf("Converted value = %lX\n", strtoul( "89ABCDEF",
           &end_ptr, 16));
           }


See Also: strtod() strtol() atof() atol()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson