A simple question about a function

X

Xiaoshen Li

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 <stdlib.h>

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.
 
X

Xiaoshen Li

I found the solution. Sorry for bothering.

endptr will point to the string(==pointer to a char array)
 
J

Jordan Abel

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 <stdlib.h>

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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,473
Latest member
ChristelPe

Latest Threads

Top