I am hoping to get some help with understanding why function definitions, with function pointer return types need to be written the following way.
<code>int ( * functionFactory (int n) ) (int, int) { Function Body }
</code>
<code>int ( * functionFactory (int n) ) (int, int) { Function Body }
</code>
int ( * functionFactory (int n) ) (int, int) { Function Body }
function definition taken from How do function pointers in C work?
This is what I imagine each part means.
<code>returned function's | function Returns | | called function's | returned function's
return type | a function pointer | name of function | arguments | arguments
| | | | |
_V_ _V_ ____________________V________ _______V_ _V______
| | | | | | | | | |
int ( * functionFactory (int n) ) (int, int) { Function Body }
</code>
<code>returned function's | function Returns | | called function's | returned function's
return type | a function pointer | name of function | arguments | arguments
| | | | |
_V_ _V_ ____________________V________ _______V_ _V______
| | | | | | | | | |
int ( * functionFactory (int n) ) (int, int) { Function Body }
</code>
returned function's | function Returns | | called function's | returned function's
return type | a function pointer | name of function | arguments | arguments
| | | | |
_V_ _V_ ____________________V________ _______V_ _V______
| | | | | | | | | |
int ( * functionFactory (int n) ) (int, int) { Function Body }
But why is it not written more like a normal function with the return type all together at the start like this.
<code>return type name of function arguments
| | |
_____V_________ _____V_______ ___V_
| | | | | |
int (*)(int, int) functionFactory (int n) { Function Body }
</code>
<code>return type name of function arguments
| | |
_____V_________ _____V_______ ___V_
| | | | | |
int (*)(int, int) functionFactory (int n) { Function Body }
</code>
return type name of function arguments
| | |
_____V_________ _____V_______ ___V_
| | | | | |
int (*)(int, int) functionFactory (int n) { Function Body }