Re: Ahead of "main"?
- From: "J. J. Farrell" <jjf@xxxxxxxxxx>
- Date: 29 Apr 2007 15:58:12 -0700
On Apr 29, 1:40 pm, "Malcolm McLean" <regniz...@xxxxxxxxxxxxxx> wrote:
"mdh" <m...@xxxxxxxxxxx> wrote in message
news:1177877117.874830.65670@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> Hi all,
Going quite methodically through K& R ( as some of you can attest
to!), I have never seen a big diffference in declaring a function
within "main" or "ahead" of it. Now, (p119, K&R II), the discussion
states that "functions "whatever" " should be declared ahead of
main.
Is there a good reason for this?
thanks.
Some early versions of C had local functions, declared within the function
that called them. The idea never caught on, and it is now not possible to
declare functions within main.
Nonsense. There is no problem declaring functions inside main or any
other function. The reasons why you may not want to do so are the
scoping rules, since the declaration would only be visible within the
same block as the declaration. On the other hand, that's perhaps
exactly why you would want to do it on the few occasions where it
makes sense to do so.
.
- References:
- Ahead of "main"?
- From: mdh
- Re: Ahead of "main"?
- From: Malcolm McLean
- Ahead of "main"?
- Prev by Date: Re: break statement in a for loop
- Next by Date: Re: String Comparision
- Previous by thread: Re: Ahead of "main"?
- Next by thread: Re: Ahead of "main"?
- Index(es):
Relevant Pages
|