This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: atof()
On Mon, Aug 19, 2002 at 10:49:53AM -0700, Reinaldo Nolasco Sanches wrote:
>
> I have a problem with atof()... and I don't understand because it...
> When I use atof() to get a value of a string... and put in my double var, the value is not the
> same...
>
> I make a little example...
>
> #include <stdio.h>
You need
#include <stdlib.h>
to get the prototype of atof.
>
> int main()
> {
> double teste;
> char strteste[10];
>
> strcpy( strteste, "120.1" );
>
> teste = atof( strteste );
>
> printf( "\n\tResult is = %.2f\n\n", teste );
>
> return 0;
> }
>
> and the result is this
>
> Result is = 1078984704.00
>
> and I don't understand this... I make this in several PCs... and in a SuSE, in a Slackware and in
> a RedHat(urgg!), and in all the erro ocurred...
>
> I don't know if I need set a specific #define... or a specific environment var...
>
> Please... anybody can help me ???
>
H.J.
- References:
- atof()
- From: Reinaldo Nolasco Sanches