0

I read that nested function don't exist in C. I then successfully executed the following piece of code using the cc command on my linux machine.

#include <stdio.h>
#include <string.h>

int main(){
    float dummy(){
        printf("hello\n");
    }
    dummy();
    return 0;
}

I got the the output hello.

How does that play out? Does my compiler support nested functions?

2 Answers2

1

GNU C supports nested functions as an extension. Your cc binary on your Linux machine is almost certainly a symlink to gcc.

jamesdlin
  • 81,374
  • 13
  • 159
  • 204
1

Nested functions don't exist in standard C. However, it might be supported as an extension in certain compilers like GNU.

tejasvi88
  • 635
  • 7
  • 15