Function strtoul () in C
The unsigned function long int strtoul (const char * str, char ** endptr, int base) in Standard C library converts part of the original string in str to a value of long int corresponding to the base base, given can be 2, 8, ..., 36, or special value 0.
The unsigned function long int strtoul (const char * str, char ** endptr, int base) in Standard C library converts part of the original string in str to a value of long int corresponding to the base base, given can be 2, 8, ., 36, or special value 0.
Declaring the function strtoul () in C
Below is the declaration for strtoul () in C:
unsigned long int strtoul ( const char * str , char ** endptr , int base )
Parameters
str - This is a string representing an integer.
endptr - This is a reference to a allocated object of type char *, whose value is set by the function to the next character in str after the numeric value.
base - This is the base, must be 2, 8, ., 36, or special value 0.
Returns the value
This function returns an integer that has been converted as a long int value. Otherwise, the function returns 0.
For example
The following program C illustrates the usage of the strtoul () function in C:
#include #include int main () { char str [ 30 ] = "21.32301 Hoc C tai QTM" ; char * ptr ; long ret ; ret = strtoul ( str , & ptr , 10 ); printf ( "Phan gia tri (unsigned long int) la: %lun" , ret ); printf ( "Phan gia tri chuoi la |%s|" , ptr ); return ( 0 ); }
Compile and run the above C program to see the results.
According to Tutorialspoint
Previous article: Function strtol () in C
Next lesson: Calloc () function in C
You should read it
- The function atoi () in C
- The atol () function in C
- The function strtod () in C
- Function strtol () in C
- Atof () function in C
- The memchr () function in C
- The function gets () in C
- Function fputs () in C
- The getchar () function in C
- The function vsprintf () in C
- Putchar () function in C
- The abort () function in C
Maybe you are interested
NASA announced its plan to search for extraterrestrial life Discovered mysterious signals emanating from a star right next to the Solar System, possibly of aliens NASA reveals its latest snapshot of the Martian surface with a resolution of 1.8 billion pixels Found the second planet of Proxima Centauri, the star closest to the sun 7 most modern astronaut ships on the planet Is Proxima b our 'neighbor' planet?