function
<cstdlib>
strtoldlong double strtold (const char* str, char** endptr);
Convert string to long double
Parses the C string str interpreting its content as a floating point number (according to the current locale) and returns its value as along double
. If endptr is not a null pointer, the function also sets the value of endptr to point to the first character after the number.
This function operates like strtod to interpret the string, but produces numbers of type long double
(see strtod for details on the interpretation process).
char*
, whose value is set by the function to the next character in str after the numerical value.
long double
.
0.0L
).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* strtold example */
#include <stdio.h> /* printf, NULL */
#include <stdlib.h> /* strtold */
int main ()
{
char szOrbits[] = "90613.305 365.24";
char * pEnd;
long double f1, f2;
f1 = strtold (szOrbits, &pEnd);
f2 = strtold (pEnd, NULL);
printf ("Pluto takes %.2Lf years to complete an orbit.\n", f1/f2);
return 0;
}
Pluto takes 248.09 years to complete an orbit.
If str does not point to a valid C-string, or if endptr does not point to a valid pointer object, it causes undefined behavior.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4