+ 3
Passing function as argument, to same function
A question has been asked here: https://www.sololearn.com/Discuss/2484139/?ref=app I don't know how it's working, since the function add() doesn't accepts any parameter, yet, it receives the add() function as an argument and calculates the sum twice https://code.sololearn.com/cMZdR8U68haX/?ref=app
4 Respuestas
+ 2
adding () will make the function evaluate,
and empty parameter function in c doesnt meant it cant recieve an argument, but it also doesnt have a way to access it either if an argument are given. so it just ignored what ever arguments passed
+ 1
Rei Shouldn't the function add() recieve a function pointer ?
And why would be the inner returned value be ignored??
+ 1
@Rei I got some stackoverflow response here, https://stackoverflow.com/questions/5929711/c-function-with-no-parameters-behavior
0
inner add() will evaluate, the return value will be used in as argument to outer add() but ignored, then outer add() evaluate