www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/11/03:14:28

Newsgroups: comp.os.msdos.djgpp
From: fredex AT fcshome DOT stoneham DOT ma DOT us (Fred Smith)
Subject: Re: Problem with DJGPP?
Organization: None!
Message-ID: <E8G8t3.3K8@fcshome.stoneham.ma.us>
References: <334C222A DOT 4F9 AT lynx DOT dac DOT neu DOT edu>
Date: Fri, 11 Apr 1997 01:15:02 GMT
Lines: 44
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

J.D. Piette (pjames AT lynx DOT dac DOT neu DOT edu) wrote:
: Hi,

: I recently downloaded DJGPP(the GCC2721 version) and RHIDE v1.2 and got
: everything set up and running fine.  BTW I think the program is
: wonderful and I am thoroughly enjoying using it.

Great!

: My problem is that when I call the function atof(), it returns a value
: of 1.00. Here is the code segment.

:    char buffer[80];
:    double price;
:    ....
:    ....
:    printf("\n\nCurrent Price?");
:    gets(buffer);
:    if(buffer[0]!='\0')
:    {
:       price=atof(buffer);
:    }

: price always has a value of 1.00.  I looked at it in the debugger and
: buffer has the correct value and if I use atoi() the correct number is
: assigned to price(the integer value).  Any information as to why this is
: happening would be greatly appreciated.  Please reply by e-mail.

I don't see a declaration of atof() (or more correctly an include that
contains the declaration) here anywhere. Most likely the compiler does not
see one either, so it ASSUMES that atof returns an int. 

You've got to make sure to include the correct headers! In this case it
should be stdlib.h.


Fred
--
---- Fred Smith -- fredex AT fcshome DOT stoneham DOT ma DOT us -- fred AT computrition DOT com ----
  "And he will be called Wonderful Counselor, Mighty God, Everlasting Father,
  Prince of Peace. Of the increase of his government there will be no end. He 
 will reign on David's throne and over his kingdom, establishing and upholding
      it with justice and righteousness from that time on and forever."
------------------------------- Isaiah 9:7 (niv) ------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019