Convert a string to a double value ? 
Author Message
 Convert a string to a double value ?

How can I convert a string to a double value ?

I'm not sure wether "atof()" returns double value and I
have heard about a function called "strtod()" ...

How do I use it with which parameters ???

Thanks !



Fri, 31 Jan 2003 03:00:00 GMT  
 Convert a string to a double value ?

Quote:
> How can I convert a string to a double value ?

> I'm not sure wether "atof()" returns double value and I
> have heard about a function called "strtod()" ...

> How do I use it with which parameters ???

> Thanks !

Although others would tell you that CLC is not a replacement
for a good reference (K&R2 or C99 or some other C text book),
I'll give you a quote from the man page on my linux box:

       #include <stdlib.h>

       double strtod(const char *nptr, char **endptr);

DESCRIPTION
       The  strtod() function converts the initial portion of the
       string pointed to by nptr to double representation.

       The expected form of the string is optional leading  white
       space  as  checked by isspace(3), an optional plus (``+'')
       or minus sign (``-'') followed by  a  sequence  of  digits
       optionally  containing  a decimal-point character, option-
       ally followed by an exponent.  An exponent consists of  an
       ``E''  or  ``e'',  followed  by  an optional plus or minus
       sign, followed by a non-empty sequence of digits.  If  the
       locale  is  not  "C"  or "POSIX", different formats may be
       used.

        Z

--
LISP is worth learning for the profound enlightenment experience you
will have when you finally get it; that experience will make you a
better programmer for the rest of your days.         Eric S. Raymond



Fri, 31 Jan 2003 03:00:00 GMT  
 Convert a string to a double value ?
Thanks, I hope that will help ... And I won't bother you again with questions answered in K&R !

Z schrieb:

Quote:

> > How can I convert a string to a double value ?

> > I'm not sure wether "atof()" returns double value and I
> > have heard about a function called "strtod()" ...

> > How do I use it with which parameters ???

> > Thanks !

> Although others would tell you that CLC is not a replacement
> for a good reference (K&R2 or C99 or some other C text book),
> I'll give you a quote from the man page on my linux box:

>        #include <stdlib.h>

>        double strtod(const char *nptr, char **endptr);

> DESCRIPTION
>        The  strtod() function converts the initial portion of the
>        string pointed to by nptr to double representation.

>        The expected form of the string is optional leading  white
>        space  as  checked by isspace(3), an optional plus (``+'')
>        or minus sign (``-'') followed by  a  sequence  of  digits
>        optionally  containing  a decimal-point character, option-
>        ally followed by an exponent.  An exponent consists of  an
>        ``E''  or  ``e'',  followed  by  an optional plus or minus
>        sign, followed by a non-empty sequence of digits.  If  the
>        locale  is  not  "C"  or "POSIX", different formats may be
>        used.

>         Z

> --
> LISP is worth learning for the profound enlightenment experience you
> will have when you finally get it; that experience will make you a
> better programmer for the rest of your days.         Eric S. Raymond



Fri, 31 Jan 2003 03:00:00 GMT  
 Convert a string to a double value ?
On Mon, 14 Aug 2000 13:00:20 +0200, Christian Zander

Quote:

>How can I convert a string to a double value ?

>I'm not sure wether "atof()" returns double value and I
>have heard about a function called "strtod()" ...

>How do I use it with which parameters ???

Try reading any good C reference, or going to
http://www.dinkumware.com/htm_cl/index.html

--
Mark McIntyre
C- FAQ: http://www.eskimo.com/~scs/C-faq/top.html



Fri, 31 Jan 2003 03:00:00 GMT  
 Convert a string to a double value ?
On Mon, 14 Aug 2000 13:00:20 +0200, Christian Zander

Quote:

>How can I convert a string to a double value ?

>I'm not sure wether "atof()" returns double value and I
>have heard about a function called "strtod()" ...

>How do I use it with which parameters ???

>Thanks !

Try sscanf.

<<Remove the del for email>>



Sat, 01 Feb 2003 12:03:26 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help: Convert string to decimal (or double)

2. Converting from double to currency string

3. about converting double to string

4. Convert a String to float/double

5. Convert String to Double

6. Converting double to string

7. IEEE-754 code to convert to and fro double/hex string

8. Converting a string containing hex to a double

9. Converting from a double to a string

10. Need function to convert float/double/long to string using a specified format

11. Q. How to convert double to string. [Newbie]

12. Convert double to string without rounding

 

 
Powered by phpBB® Forum Software