Last active
December 23, 2015 20:09
-
-
Save i/6688016 to your computer and use it in GitHub Desktop.
Another example of function pointers in C.
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
#include <stdio.h> | |
int add(int a, int b) { | |
return a + b; | |
} | |
int main(int argc, char **argv) { | |
int ret; | |
int (*fn_ptr)(int a, int b); | |
fn_ptr = add; | |
ret = fn_ptr(3,6); | |
printf("%d\n", ret); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment