Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
struct func {
int (*add)(int i, int j);
int (*sub)(int i, int j);
};
int add(int i, int j)
{
return i + j;
}
int sub(int i, int j)
{
return i - j;
}
int main()
{
struct func *f;
f = malloc(sizeof(struct func));
f->add = add;
f->sub = sub;
printf("%d\n", f->add(10, 20));
printf("%d\n", f->sub(30, 20));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.