Scroll Down to See All▾
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1ynFunction Details : strtod
doublestrtod(const char * str,char ** endptr) ;
Return Type : double
Double-precision floating point (±1.7E±308, ~15 decimal digits)
Read about return values of strtod function .
1st Parameter Type : const char *
Pointer to read-only string
1st Parameter
Pointer to the null-terminated string to be converted to a `double`. The string may represent a floating-point value, optionally preceded by whitespace and a sign.
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 pointer that will be set to the character after the last valid character used in the conversion. Can be `NULL` if this information is not needed.
Read more about parameters of strtod in parameters section
The strtodfunction in C language Converts the initial portion of the string to a double-precision floating-point number.
The strtod function converts the initial portion of the string pointed to by nptr to a double. It skips leading whitespace, converts the subsequent characters as part of the number, and stops at the first character it cannot recognize as part of a number. If endptr is not NULL, it stores the address of the first invalid character in *endptr.
The strtodfunction takes 2
parameters:Converts the initial portion of the string `str` to a `double` value. If `endptr` is not `NULL`, it is set to point to the first character after the converted value. Returns the converted `double` value or `0.0` if no valid conversion could be performed. Handles special values like `INF` or `NAN` if supported.
- •const char * `str`: Pointer to the null-terminated string to be converted to a `double`. The string may represent a floating-point value, optionally preceded by whitespace and a sign.
- •char ** `endptr`: Pointer to a pointer that will be set to the character after the last valid character used in the conversion. Can be `NULL` if this information is not needed.
The strtod function return value :
- Returns the converted double value
- If no conversion could be performed, 0
- 0 is returned
- If the correct value is outside the range of representable values, HUGE_VAL (with the correct sign) is returned and errno is set to ERANGE
Output
This example demonstrates basic usage of strtod to convert a string to a double and identify the remainder of the string.