445,918 Members | 2,246 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

# A simple question about a function

 P: n/a Dear All, I am puzzled by how to use strtod(). I have pasted its man page below. I don't understand what char **endptr is and why it is needed there. Thank you very much. STRTOD(3) Library functions STRTOD(3) NAME strtod, strtof, strtold - convert ASCII string to floating point number SYNOPSIS #include double strtod(const char *nptr, char **endptr); float strtof(const char *nptr, char **endptr); long double strtold(const char *nptr, char **endptr); DESCRIPTION The strtod, strtof, and strtold functions convert the initial portion of the string pointed to by nptr to double, float, and long double representation, respectively. Dec 16 '05 #1
3 Replies

 P: n/a On 2005-12-16, Xiaoshen Li wrote: Dear All, I am puzzled by how to use strtod(). I have pasted its man page below. I don't understand what char **endptr is and why it is needed there. Thank you very much. STRTOD(3) Library functions STRTOD(3) NAME strtod, strtof, strtold - convert ASCII string to floating point number SYNOPSIS #include double strtod(const char *nptr, char **endptr); float strtof(const char *nptr, char **endptr); long double strtold(const char *nptr, char **endptr); DESCRIPTION The strtod, strtof, and strtold functions convert the initial portion of the string pointed to by nptr to double, float, and long double representation, respectively. If that's the whole manpage, then you have a crappy manpage. An exerpt from my manpage: RETURN VALUES The strtod(), strtof(), and strtold() functions return the converted value, if any. If endptr is not NULL, a pointer to the character after the last character used in the conversion is stored in the location referenced by endptr. If no conversion is performed, zero is returned and the value of nptr is stored in the location referenced by endptr. Dec 16 '05 #2

 P: n/a I found the solution. Sorry for bothering. endptr will point to the string(==pointer to a char array) Xiaoshen Li wrote: Dear All, I am puzzled by how to use strtod(). I have pasted its man page below. I don't understand what char **endptr is and why it is needed there. Thank you very much. STRTOD(3) Library functions STRTOD(3) NAME strtod, strtof, strtold - convert ASCII string to floating point number SYNOPSIS #include double strtod(const char *nptr, char **endptr); float strtof(const char *nptr, char **endptr); long double strtold(const char *nptr, char **endptr); DESCRIPTION The strtod, strtof, and strtold functions convert the initial portion of the string pointed to by nptr to double, float, and long double representation, respectively. Dec 16 '05 #3

 P: n/a Please do not top-post. Xiaoshen Li wrote: [Question: How to use strtod(), especially the char** parameter] I found the solution. Sorry for bothering. endptr will point to the string(==pointer to a char array) Here is an example how to use strtol(); you should be able to adapt it to strtod(): http://home.att.net/~jackklein/c/code/strtol.html Cheers Michael -- E-Mail: Mine is an /at/ gmx /dot/ de address. Dec 16 '05 #4

### This discussion thread is closed

Replies have been disabled for this discussion.