0

How to point to a function that returns a pointer

I have following code: typedef struct{ int age; }PERSON; PERSON *func(PERSON *person){ person->age=43; return person; } void main() { PERSON new={6}; PERSON *ptr; PERSON (*pointToFunction)(PERSON *)=&func; ptr=(*pointToFunction)(&new);//When I do that I get an error called "initialization from incompatible type [-Wincompatible-pointer-types] } How can I fix it?

7th Jan 2018, 9:57 PM
Yusuf
Yusuf - avatar
3 ответов
+ 3
I remembered the method that you used. I have forgotten the logic of pointing to a function. Thank you @kurwius
7th Jan 2018, 10:59 PM
Yusuf
Yusuf - avatar
+ 3
For the future: When asking questions involving code, link to the code instead of copy & paste. Makes it easier to read and test.
8th Jan 2018, 12:27 AM
Jacob Pembleton
Jacob Pembleton - avatar
+ 1
I will consider it @Jacob Pembleton
8th Jan 2018, 7:37 AM
Yusuf
Yusuf - avatar