Created
July 12, 2012 17:59
-
-
Save dskinner/3099713 to your computer and use it in GitHub Desktop.
typedef test
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> | |
#include <stdlib.h> | |
typedef int (*oper_cb)(int a, int b); | |
int add(int a, int b) | |
{ | |
return a + b; | |
} | |
int sub(int a, int b) | |
{ | |
return a - b; | |
} | |
int test_oper(int a, int b, oper_cb cb) | |
{ | |
return cb(a, b); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
printf("%d\n", test_oper(4, 3, add)); | |
printf("%d\n", test_oper(4, 3, sub)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment