Created
March 26, 2017 20:00
-
-
Save jweinst1/7945399c2b3c59517d775c0194718085 to your computer and use it in GitHub Desktop.
basic function pointer example in c
This file contains 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> | |
#include <stdlib.h> | |
//c function pointer example | |
int addInt(int n, int m); | |
int addInt(int n, int m) { | |
return n+m; | |
} | |
int main() { | |
int (*functionPtr)(int,int); | |
functionPtr = &addInt; | |
int sum = (*functionPtr)(2, 3); | |
printf("The sum is %d", sum); | |
//The sum is 5 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment