Last active
June 1, 2017 05:24
-
-
Save hackjutsu/21b61e61b70b5f1893f1e1f2fdfee19b to your computer and use it in GitHub Desktop.
[Function pointer example] Function #pointers are somewhat different than all other types because the syntax does not follow the pattern typedef <old type name> <new alias>; Instead, the new alias for the type appears in the middle between the return type (on the left) and the argument types (on the right).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef int (*MathFunc)(float, int); | |
int do_math(float arg1, int arg2) { | |
return arg2; | |
} | |
int call_a_func(MathFunc call_this) { | |
int output = call_this(5.5, 7); | |
return output; | |
} | |
int final_result = call_a_func(&do_math); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment