home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!decwrl!world!ksr!jfw
- From: jfw@ksr.com (John F. Woods)
- Newsgroups: comp.lang.c
- Subject: Re: problems with atof()
- Message-ID: <15055@ksr.com>
- Date: 21 Aug 92 14:45:46 EDT
- References: <1992Aug20.125252.3451@dxcern.cern.ch>
- Sender: news@ksr.com
- Lines: 22
-
- nilo@atdigarfield.cern.ch (Operator) writes:
- > I have a problem withe the atof() function, you know string to double
- >conversion.
- > #include <stdio.h>
- > #include <ctype.h>
- > main()
- > {
- > double a[2];
- > char *b="-.345"
- > printf("this is b : %f %s \n",atof(b),b);
-
- > a[0] = atof(b);
-
- You have not declared atof() before using it, therefore you have told the
- compiler that it returns an int. It does not, as you know. You lied to the
- compiler, and it extracted its revenge.
-
- Either add a declaration somewhere appropriate, like
- double atof( /* char *string */ ); /* for ANSI C, uncomment the
- * parameter declaration */
- or (if you have ANSI C) you can add
- #include <stdlib.h>
-