Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
This concept checks whether ISO C permits nested function definitions. Some compilers (like GCC) offer an extension for nested functions, which can cause confusion. Standard C forbids defining a function inside the body of another function.
Given Data / Assumptions:
Concept / Approach:
In standard C, a function definition has external or file scope and cannot be nested in the compound statement of another function. Placing a full definition within another function violates the grammar. GCC’s nested functions are a nonportable extension and should not be relied upon in portable code.
Step-by-Step Solution:
Interpret the statement under ISO C rules.Note: Only declarations (prototypes) are permitted inside blocks; definitions are not.Therefore, the statement is correct for standard C.
Verification / Alternative check:
Attempting “void outer(){ void inner(){} }” in a strict standard C mode (e.g., -std=c11 -pedantic) produces an error. Moving inner to file scope resolves it.
Why Other Options Are Wrong:
Incorrect/inline/static/linker options: none change the language grammar that forbids nested definitions.
Common Pitfalls:
Confusing declarations with definitions; assuming behavior seen with a GNU extension is portable.
Final Answer:
Correct
Discussion & Comments