[Tutor] Newbie problems

dman dsh8290@rit.edu
Wed, 6 Mar 2002 00:01:15 -0500


On Tue, Mar 05, 2002 at 02:49:16PM -0800, Danny Yoo wrote:

[lots of good stuff]
 
| [Aside: skip this if you haven't seen C before]
 
| Without the function prototypes at the top, C gets totally confused and
| hollers that we have no idea what we're doing.  *grin*.  This is a strong
| reason why C uses function prototypes, so that C knows up front what
| functions will be available.

Just to nitpick, the C standard doesn't require prototypes.  The
compiler just assumes that you (the programmer) know what you are
doing and that you did it right.  It also assumes that functions
return 'int' if they weren't previously declared.  You may get wacky
linker errors, though, if your calls don't match the types in the
function's signatures.  There are options to gcc to make it require
the prototypes, which I think are a good idea!  In conrast, C++
requires prototypes regardless and to leave it out is a fatal error.

-D

-- 

Even youths grow tired and weary,
    and young men stumble and fall;
but those who hope in the Lord 
    will renew their strength.
They will soar on wings like eagles;
    they will run and not grow weary,
    they will walk and not be faint.

        Isaiah 40:31