Skip to content

Instantly share code, notes, and snippets.

@dskinner
Created July 12, 2012 17:59
Show Gist options
  • Save dskinner/3099713 to your computer and use it in GitHub Desktop.
Save dskinner/3099713 to your computer and use it in GitHub Desktop.
typedef test
#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