Scroll Down to See All▾
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1ynFunction Details : strtoul
unsigned longstrtoul(const char * nptr,char ** endptr,int base) ;
Return Type : unsigned long
Large integer type (4 or 8 bytes, non-negative values)
Read about return values of strtoul function .
1st Parameter Type : const char *
Pointer to read-only string
1st Parameter
Pointer to the null-terminated string to be converted to an `unsigned long` integer.
2nd Parameter Type : char **
A pointer to a pointer to a null-terminated string. Commonly used in functions like `strtol` and `strtok_r` to store the address of the first invalid character or to maintain state across function calls.
2nd Parameter
Pointer to a `char *` that will store the address of the first invalid character after the number in `nptr`. Can be `NULL` if this information is not needed.
3rd Parameter Type : int
Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
3rd Parameter
The base of the number in `nptr` (e.g., 10 for decimal, 16 for hexadecimal). If 0, the base is automatically detected from the string prefix (`0x` for hex, `0` for octal, or decimal otherwise).
Read more about parameters of strtoul in parameters section
The strtoulfunction in C language Converts the initial portion of the string to an unsigned long integer.
The strtoul function converts the initial part of the string in nptr to an unsigned long int value according to the given base, which must be between 2 and 36 inclusive, or be the special value 0. It skips leading whitespace and stops at the first character it cannot recognize as part of a number.
The strtoulfunction takes 3
parameters:Converts the initial portion of the string pointed to by `nptr` to an `unsigned long` integer according to the specified `base`. The conversion stops at the first invalid character. If `endptr` is not NULL, it points to the character following the valid number. Returns the converted value or `ULONG_MAX` on overflow.
- •const char * `nptr`: Pointer to the null-terminated string to be converted to an `unsigned long` integer.
- •char ** `endptr`: Pointer to a `char *` that will store the address of the first invalid character after the number in `nptr`. Can be `NULL` if this information is not needed.
- •int `base`: The base of the number in `nptr` (e.g., 10 for decimal, 16 for hexadecimal). If 0, the base is automatically detected from the string prefix (`0x` for hex, `0` for octal, or decimal otherwise).
The strtoul function return value :
- Returns the converted unsigned long int value
- If no conversion could be performed, 0 is returned
- If the correct value is outside the range of representable values, ULONG_MAX is returned, and errno is set to ERANGE
Output
This example demonstrates basic usage of strtoul to convert a string to an unsigned long integer and identify the remainder of the string.