Can we declare functions inside functions?

c, function

Solution

Yes, you can declare, but you cannot define. Also, you can declare function as many times you want, but define only once.

Problem

``` #include <stdio.h> int main() { void foo(); printf("1 "); foo(); } void foo() { printf("2 "); } ``` Output: ``` 1 2 ``` How declaring functions inside functions work? Does it mean that foo() function can only be called by main()?

Original source