Can we declare functions inside functions?

#include <stdio.h>

int main()
{
   void foo();
   printf("1 ");
   foo();
}

void foo()
{
    printf("2 ");
}

Output:

1 2

How are functions declared inside functions? Does this mean that the function foo () can only be called main ()?

+4
source share
1 answer

Yes, you can declare, but you cannot determine. In addition, you can declare a function as many times as you want, but define only once.

+12
source

Source: https://habr.com/ru/post/1524552/


All Articles