🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #42675

Re: Programmer error (was Re: scanf problem in TC v2.01.)

#42675
From: Rick Schaut
Date: Mon, 19 Feb 1990 20:24
27 lines
1764 bytes
In article <2126@rodan.acs.syr.edu> jfbruno@rodan.acs.syr.edu (John F. Bruno) writes:
| 
| In article <204@sdscal.UUCP> keith@sdscal.UUCP (Keith Jones) writes:
|  [A C program that printed a value of Pi after a call to atof().]
|  
| atof() takes a character pointer as its argument and returns a float, in C,
| anytime you don't explicitly declare what a function returns, it is assumed
| to be an integer (I know, I would prefer a warning also), that's what 
			    ^^^^^^^^^^^^^^^^^^^^^^^^
| happened in this case, because you didn't #include <math.h> I got the same
| result with my test program, but when you include the prototype for atof(),
| it works perfectly. If you look up atof() in the Turbo-C reference guide, it
| says "prototype in math.h,stdlib.h"

Um, there _is_ a command-line switch that turns such warnings on.  If you
don't like having to type the switch every time, look-up turboc.cfg in
the User's Guide.

Whenever I get a question about a bug, the first two questions I ask are,
"did you turn on _all_ warnings before compiling", and "did your sample
code compile without any such warnings".  If the answer to _either_ question
is no, I send the person back to try again.

--
Rick (schaut@garfield.cs.wisc.edu)

Peace and Prejudice Don't Mix! (unknown add copy)
Technical Details
Message-ID: <4321@daffy.cs.wisc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!uwvax!daffy!cat9.cs.wisc.edu!schaut
References: <204@sdscal.UUCP> <2126@rodan.acs.syr.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!uwvax!daffy!cat9.cs.wisc.edu!schaut
From: schaut@cat9.cs.wisc.edu (Rick Schaut)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Programmer error (was Re: scanf problem in TC v2.01.)
Message-ID: <4321@daffy.cs.wisc.edu>
Date: 19 Feb 90 20:24:09 GMT
References: <204@sdscal.UUCP> <2126@rodan.acs.syr.edu>
Sender: news@daffy.cs.wisc.edu
Organization: U of Wisconsin CS Dept
Lines: 27