User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdlib.h:strtoul

strtoul

    #include <stdlib.h>
    unsigned long int strtoul(const char *str, char **endptr, int base);

strtoul Converting a string to an unsigned long integer
str: the string to be converted
endptr: address of a pointer variable that points to the last character read, so the character that is not owned by a number
base: base between 2 and 36

Be found unprefixed numbers, these numbers in base 10 are accepted.
If the base '0 'is specified, the strings make a reference to the basis used
(leading “0x” for hexadecimal, “0” for octal, numbers).

strtoul c code example

/* 
 * strtoul example code
 * http://code-reference.com/c/stdlib.h/strtoul
 */
#include <stdio.h>
#include <stdlib.h>
 
int main ( void )
{
  char string[] ="20405";
  char *endptr;
  unsigned long int number;
 
  number = strtoul(string, &endptr, 10);
  printf("string is %s\n",string);
  printf("unsigned long int is %li\n", number);
 
  return 0;
}

Output of strtoul example

  user@host:~$ ./strtoul
  string is 20405
  unsigned long int is 20405

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/strtoul.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz