Created
May 24, 2013 13:17
-
-
Save psyomn/5643435 to your computer and use it in GitHub Desktop.
How to give children nightmares at night.
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
| /* | |
| * How to give children nightmares at night. | |
| */ | |
| #include <stdio.h> | |
| int func_a(int a, int b){ return a + b; } | |
| int func_b(int a, int b){ return a - b; } | |
| int func_c(int a, int b){ return a * b; } | |
| int func_d(int a, int b){ return a / b; } | |
| int main(int argc, char ** argv) | |
| { | |
| int i; | |
| int (*f[4])(int, int); | |
| f[0] = func_a; | |
| f[1] = func_b; | |
| f[2] = func_c; | |
| f[3] = func_d; | |
| for (i = 0; i < sizeof(f) / sizeof(int *); ++i) | |
| { | |
| printf("%d\n", (*f[i])(2, 5)); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment