Re: Ahead of "main"?



On Apr 29, 2:35 pm, "Stephen Sprunk" <step...@xxxxxxxxxx> 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?

In Standard C, functions cannot be declared "within" main(); these are
called nested functions ...

No, they're called function declarations are are certainly allowed
within main() and any other function. You're confusing declaration
with definition. You can't define a function within another function
in Standard C.

.



Relevant Pages

  • Re: What is Negative Energy ???
    ... and then declaring, on the basis on his declaration to being a ... I 'll remind him of that standard applied to him, ... a lack of precision, to remind him a reasonable standard of precision ...
    (sci.physics.relativity)
  • Re: Find the size of a datatype
    ... Suppose I am given a datatype say X in C. ... without declaring a variable or pointer variable of that type, ... of course without using sizeof operator. ... standard will tell you how big an int is. ...
    (comp.lang.c)
  • Re: Find the size of a datatype
    ... Suppose I am given a datatype say X in C. ... without declaring a variable or pointer variable of that type, ... course without using sizeof operator. ... standard will tell you how big an int is. ...
    (comp.lang.c)
  • Re: Cases where Forth seems a little clunky
    ... returning zero. ... Simply declaring that none of these words can ever ... The point would be that this would likely end up in the new standard ... M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html ...
    (comp.lang.forth)
  • Ahead of "main"?
    ... Going quite methodically through K& R (as some of you can attest ... I have never seen a big diffference in declaring a function ... Is there a good reason for this? ...
    (comp.lang.c)