Pointers to Functions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Pointers to Functions

int function(int (*take)(int a)); int function2(int *take(int a)); What is the difference between those pointers? And how can I implement those pointers with functions?

4th Dec 2017, 7:37 PM
Yusuf
Yusuf - avatar
2 Answers
+ 1
First of all, you should make this program global. Because it is a really good example. Also, what does the func2 return? Is it returning address of a pointer?And why are you casting something as int *?It doesn't make sense for me. Because they are passing to the function take with their own address. And we has a pointer in function parameter. The pointer should take the address of what we passed.
4th Dec 2017, 9:28 PM
Yusuf
Yusuf - avatar
+ 1
Thank you for everything. I guess we just need to cast for functions. There is no need to cast for others. @kurwius
4th Dec 2017, 10:47 PM
Yusuf
Yusuf - avatar