English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

c language question

2006-07-03 18:00:22 · 4 answers · asked by engg 1 in Computers & Internet Programming & Design

4 answers

The programmers didn't see a reason to include them at the time. That's part of the reason C++ was created.

2006-07-03 18:06:03 · answer #1 · answered by Leon 5 · 0 0

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.)

2006-07-04 01:16:45 · answer #2 · answered by george 4 · 0 0

What do you mean by nested functions? You can have function calls within the body of a function, so you can make them as nested as you like. Maybe I don't know what you're asking . . . could you explain better?

2006-07-04 01:04:42 · answer #3 · answered by anonymous 7 · 0 0

Why would it need them?

2006-07-04 01:03:33 · answer #4 · answered by bobhayes 4 · 0 0

fedest.com, questions and answers