Re: Ahead of "main"?
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 17:42:39 -0400
mdh wrote:
On Apr 29, 1:41 pm, Eric Sosman <esos...@xxxxxxxxxxxxxxxxxxx> wrote:[...][...]
Here's a point to ponder: A function definition --..... also declares it (two
two-syllable verbs both beginning with DE, but they are not
the same). It is possible to declare a function without
defining it,......
So, if I understand you correctly, in my case for a small program, the
key seems to be to understand that a declaration needs to occur prior
to the function being called.
Where that declaration actually occurs (prior to main, or within main)
( under these limited circumstances) is of no consequence. However,
once one gets into the "real" world of C, this would be good
programming ( as you noted with seperate .h files), so I may as well
get used to practising good style!!
I think you are still confusing "declaration" and
"definition." You should declare every function before
trying to call it (modern compilers change "should" to
"must"), but you can define the function wherever you
like. Since a definition is also a declaration (but not
vice-versa), if you define the function before calling
it you don't need a separate declaration. If you define
the function after calling it, or if you define it in a
separately-compiled file, you need a declaration prior
to the first call.
Eventually this will make sense. Trust me.
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: Ahead of "main"?
- From: mdh
- Re: Ahead of "main"?
- References:
- Ahead of "main"?
- From: mdh
- Re: Ahead of "main"?
- From: Eric Sosman
- Re: Ahead of "main"?
- From: mdh
- Ahead of "main"?
- Prev by Date: Re: break statement in a for loop
- Next by Date: Re: Initialization of an array and symbolic names for index
- Previous by thread: Re: Ahead of "main"?
- Next by thread: Re: Ahead of "main"?
- Index(es):
Relevant Pages
|