Mail Archives: djgpp/1999/09/06/11:06:31
On Sun, 5 Sep 1999, Berti Drost wrote:
> If I add
> #include <stdlib.h>
> it works correctly, if I don't, it can be compiled, but atof returns strange
> numbers; I wonder why...
Because C assumes that any function without a prototype returns an
int. <stdlib.h> includes a prototype of `atof' that says it returns a
double, but if you omit it, the compiler generates code that
interprets the value returned by `atof' as an int, which indeed will
produce very strange results.
You should *always* include the headers with the prototypes of all the
library functions your program uses. That is why the documentation
for every function in the DJGPP library reference always shows you
what header has the prototype.
- Raw text -