Path: 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 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 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)