Skip to content

Instantly share code, notes, and snippets.

@psyomn
Created May 24, 2013 13:17
Show Gist options
  • Select an option

  • Save psyomn/5643435 to your computer and use it in GitHub Desktop.

Select an option

Save psyomn/5643435 to your computer and use it in GitHub Desktop.
How to give children nightmares at night.
/*
* 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