Possible duplicate:
Are nested functions bad in gcc?
As far as I know, C does not allow you to define a function within another function. But the following code compiles and runs without errors in gcc. Can someone explain the reason? See Also: http://ideone.com/AazVK
#include <stdio.h> void val1( int x ) { void sig( int x ) { printf("%d\n",x*10); } sig(x); } int main() { void val2(int x) { x = x*10; val1(x); printf( "%d\n", x ); if ( x < 10000 ) { val2(x); } } val2(20); return 0; }
c
kiesel-x
source share