Skip to content

Instantly share code, notes, and snippets.

@jweinst1
Created March 26, 2017 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jweinst1/7945399c2b3c59517d775c0194718085 to your computer and use it in GitHub Desktop.
Save jweinst1/7945399c2b3c59517d775c0194718085 to your computer and use it in GitHub Desktop.
basic function pointer example in c
#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