Created
October 29, 2015 14:13
-
-
Save kokosabu/65664512fc7c5f930760 to your computer and use it in GitHub Desktop.
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> | |
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