Newsgroups: comp.os.msdos.djgpp From: Steve Gibson Subject: Re: Problem with DJGPP? Content-Type: text/plain; charset=us-ascii Message-ID: <33572013.3021@ccis.adisys.com.au> Sender: usenet AT ccis DOT adisys DOT com DOT au (usenet) Nntp-Posting-Host: herring Reply-To: gibson AT ccis DOT adisys DOT com DOT au Content-Transfer-Encoding: 7bit Organization: ADI Limited References: <334C222A DOT 4F9 AT lynx DOT dac DOT neu DOT edu> Mime-Version: 1.0 Date: Fri, 18 Apr 1997 07:17:39 GMT Lines: 58 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Fred Smith wrote: > > 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. > Yeh! If you're not carefull to use prototypes / headers correctly that can be a real trap. I spent one (not so) memorable late night / early morning a tracking down a very similar problem to the one described. Once you figure out what is hapening, it's *obvious* D'oH ! Later SG -- Steve Gibson ADI Limited, CCIS Systems Group Email: gibson AT ccis DOT adisys DOT com DOT au Snail: 22 Stirling Hwy Nedlands Western Australia Nbrs : (tel) +61 9 333 8917 (fax) +61 9 333 8889