C error which worked fine

Henry Spencer henry at utzoo.uucp
Fri Feb 10 09:49:05 AEST 1989


In article <7631 at techunix.BITNET> ssreefc at techunix.BITNET (florin coter) writes:
>the undeclared fopen sould have been assumed of type int and not FILE *...
>so why did it work ok?

First, are you sure you didn't include <stdio.h>, which declares those things?
Second, in many (not all!) C implementations, pointers and ints are the
same size and are handled much the same way, so you can sometimes get
away with lying to the compiler about the type of returned values, because
it treats them the same way regardless.
-- 
The Earth is our mother;       |     Henry Spencer at U of Toronto Zoology
our nine months are up.        | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list