Basic and Advance C Question:
Download Job Interview Questions and Answers PDF
Why doesnt C have nested functions?
Answer:
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.)
Download C Programming Interview Questions And Answers
PDF
Previous Question | Next Question |
What is assert and when would I use it? | Does C have an equivalent to Pascals with statement? |