Last active
December 14, 2015 05:19
-
-
Save tafryn/5034232 to your computer and use it in GitHub Desktop.
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> | |
struct { | |
int first; | |
int second; | |
}typedef myStruct; | |
int getFirst (myStruct* a) { return (*a).first; } | |
int getSecond (myStruct* a) { return (*a).second; } | |
int sum(myStruct* a, myStruct* b, int (*pt2Func)(myStruct*)) { | |
int result = pt2Func(a) + pt2Func(b); | |
return result; | |
} | |
void main() { | |
myStruct sOne = {1,2}; | |
myStruct sTwo = {10,100}; | |
printf("Sum First: %d\n", sum(&sOne, &sTwo, &getFirst)); | |
printf("Sum Second: %d\n", sum(&sOne, &sTwo, &getSecond)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment