@rahul In Standard C you cant define a function inside another function but you can declare a function inside another function. (so the function can be defined outside the function). Eg:- #include<stdio.h> void abc() { printf("bac"); void abf(); abf(); }
void abf() { printf("bas"); getchar(); } int main() { abc(); getchar(); } coming to Gcc has a language extension that allows nested functions. so this is entirely compiler dependent. On Wed, Oct 3, 2012 at 12:39 PM, kranthi kumar <damarlakran...@gmail.com>wrote: > In C, there is no difference between rules for declaring and defining > function and variable. So we can define the functions inside another > function, but their scope is limited to that function only, > In this example abf() is local function to abc(), it can't be > accessed outside environment. > > > On Wed, Oct 3, 2012 at 1:06 AM, rahul sharma <rahul23111...@gmail.com>wrote: > >> Guys i have read that we cant define function in another function in c >> Then why this followung program running fine on gcc >> >> #include<stdio.h> >> void abc() >> { >> printf("bac"); >> void abf() >> { >> printf("bas"); >> getchar(); >> } >> } >> int main() >> { >> abc(); >> getchar(); >> } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Regards: > -------------------- > Kranthi Kumar D > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > Regards, Srikanth. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.