Reputation:
If a function(say a()) prototype is declared inside a function(say main()) does it mean that it cannot be used in functions other that main() function?
Upvotes: 3
Views: 155
Reputation: 663
In general things that you are able to declare inside a function (e.g. variables) are only in use for that function.
Upvotes: -1
Reputation: 612854
Yes that is correct. That is true for all declarations within a particular scope. They are only available within the defining scope.
Of course, you can declare the same function in another scope, but I don't think that's what you meant.
Upvotes: 0
Reputation: 506897
No that does not mean that. If the other functions declare it too, then the function can be used by those other functions too.
int main(void) {
void f(void);
f();
}
void g(void) {
void f(void);
f();
}
In this example, main
declared function f
locally and called it. But g
does that same thing too. Both declarations refer to the same function.
Upvotes: 3