Mail Archives: djgpp/1999/05/09/22:00:36
From: | Martin Ambuhl <mambuhl AT earthlink DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: atof(...) Problem
|
Date: | Sun, 09 May 1999 21:00:25 -0400
|
References: | <3735C5E2 DOT AB4BEBE2 AT t-online DOT de>
|
X-Posted-Path-Was: | not-for-mail
|
X-Accept-Language: | en
|
X-ELN-Date: | 10 May 1999 00:59:18 GMT
|
X-ELN-Insert-Date: | Sun May 9 18:05:10 1999
|
Organization: | Nocturnal Aviation
|
Lines: | 39
|
Mime-Version: | 1.0
|
NNTP-Posting-Host: | dialup-209.246.103.161.newyork2.level3.net
|
Message-ID: | <37362FA9.2073A1C3@earthlink.net>
|
X-Mailer: | Mozilla 4.51 [en] (Win95; I)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Jan wrote:
>
> If I use the "atof" function I get always "1.0000000":
> {
> double d;
> char Test[80];
>
> strcpy(Test, "123.456");
> d = atof(Test);
> printf("'%f'\n", d); // result is "1.000000"
> }
> If I give the number direct ( atof("123.456") ) or a pointer to
> a string, I get always "1.0.....".
I find that really hard to believe. When we turn you snippet into a program:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
double d;
char Test[80];
strcpy(Test, "123.456");
d = atof(Test);
printf("'%f'\n", d);
d = atof("123.456");
printf("'%f'\n", d);
return 0;
}
The output is:
'123.456000'
'123.456000'
--
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive
- Raw text -