we does not have nested functions in c because we use concept of friend function
satish
Aug 26th, 2005
We don't have anything like friend function in C it is in C++
praveena
Jul 31st, 2006
since it has friend function it doesnt have nested function
s.vamsikrishna
Nov 17th, 2006
c does not have nested functions because c doesnot not support encapsulation.in c each and every function is independent to each other and performs its assigned task separately
priti
Jan 18th, 2007
#include<stdio.h> int add(int a,int b) { int c=3; int d=a+b; int addToC(int c, int d ) { printf("This is addToC.....n"); return(c+d); } return(addToC(c,d)); } int main() { printf(" Addition %d n" ,add(1,2)); return 0; }
govardhan
Apr 20th, 2007
It's not trivial to implement nested functions such that they have the proper access to local variables in the containing function(s), so they were deliberately left out of C as a simplification. (gcc does allow them, as an extension.) For many potential uses of nested functions (e.g. qsort comparison functions), an adequate if slightly cumbersome solution is to use an adjacent function with static declaration, communicating if necessary via a few static variables. (A cleaner solution, though unsupported by qsort, is to pass around a pointer to a structure containing the necessary context.)
Why doesn't C have nested functions?