Topic: Conversion of Char Array into Floating Point Number


Author: antony@sixgun.demon.co.uk (Antony Scott)
Date: Tue, 27 Dec 1994 14:49:27 +0000
Raw View
In article <3csggo$l16@newsbf01.news.aol.com>
           jrode51273@aol.com "JRode51273" writes:

> I am trying to learn Turbo C++ and have a Question.  I have created a
> Character
> Array to hold a Floating Point Number(The reason for the Array instead of
> declaring it as a floating point number was so I could control the output
> of what the input was onscreen), anyway - How can a Character array be
> converted into a floating point number - Any ideas - Anybody - Anybody?

You could try using the atof function.

char *Data = "56.2";
float Num = atof(Data);

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Antony Scott, antony@sixgun.demon.co.uk
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




Author: mwt@lightside.com (Mark Thompson)
Date: 16 Dec 1994 17:23:19 GMT
Raw View
In article <3csggo$l16@newsbf01.news.aol.com>, jrode51273@aol.com (JRode51273) says:
>
>I am trying to learn Turbo C++ and have a Question.  I have created a
>Character
>Array to hold a Floating Point Number(The reason for the Array instead of
>declaring it as a floating point number was so I could control the output
>of what the input was onscreen), anyway - How can a Character array be
>converted into a floating point number - Any ideas - Anybody - Anybody?

Try atof()


Mark Thompson
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=
Micro Masters            Personal/Business --> mwt@lightside.com
PO Box 1709                         School --> 1MWT0323@ibm.mtsac.edu
Covina, CA  91722                              Phone:  (818) 332-5998
The opinions given really do represent those of Micro Masters, though
they probably aren't really my own.




Author: jrode51273@aol.com (JRode51273)
Date: 16 Dec 1994 11:50:32 -0500
Raw View
I am trying to learn Turbo C++ and have a Question.  I have created a
Character
Array to hold a Floating Point Number(The reason for the Array instead of
declaring it as a floating point number was so I could control the output
of what the input was onscreen), anyway - How can a Character array be
converted into a floating point number - Any ideas - Anybody - Anybody?