C
Curious Student
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 <I>only</I>:
int myfunction(int, int);
int main(void)
{
int a,b;
return myfunction(a,b);
}
But I've also seen:
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?
instead of in the global declaration space, which I thought was the
way.
I thought it was <I>only</I>:
int myfunction(int, int);
int main(void)
{
int a,b;
return myfunction(a,b);
}
But I've also seen:
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?