can anyone explain these lines to me:
int xyz( void )
{
extern void abc( void );
}
a function declaration within a function definition? or am I missunderstanding something?
Nested function is not supported by C because we cannot define a function within another function in C. We can declare a function inside a function, but it's not a nested function.
A function which is defined inside another function is known as inner function or nested functio n. Nested functions are able to access variables of the enclosing scope. Inner functions are used so that they can be protected from everything happening outside the function. This process is also known as Encapsulation .
Syntax to Call a Function We can call a C function just by passing the required parameters along with function name. If function returns a value, then we can store returned value in a variable of same data type. int sum = getSum(5, 7); Above statement will call a function named getSum and pass 5 and 7 as a parameter.
C does not enable nested functions because we cannot define a function within another function in C. It is possible to declare a function within a function, but this is not a nested function.
Yes, your guess is correct. It's declaring the existence of the function abc()
, so it may be referenced within xyz()
. Note that the extern
is unnecessary, as functions are extern
by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With