|
-
Jun 19th, 2004, 03:46 PM
#1
Thread Starter
Junior Member
What's it with this kind of definition?
Some places till now, I've seen function prototypes within functions instead of in the global declaration space, which I thought was the way.
I thought it was only:
Code:
int myfunction(int, int);
int main(void)
{
int a,b;
return myfunction(a,b);
}
But I've also seen:
Code:
int main(void)
{
int a, b, myfunction(int, int);
return myfunction(a,b);
}
I've seen this in K&R as well, but haven't come accross a piece that talks about this kinda declaration.
What's the deal here? I understand it as follows:
It defines the scope of usage. If defined in the global space, much like extern variables, the function can be called from anywhere within the file. If declared within another function, it may be called only from within that function in which it is defined.
How true?
-
Jun 20th, 2004, 03:16 AM
#2
Never seen that actually used, although I know it's legal. I don't think it's a good idea though.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|