Skip to content

Instantly share code, notes, and snippets.

@ku
Created November 19, 2008 05:32
Show Gist options
  • Save ku/26430 to your computer and use it in GitHub Desktop.
Save ku/26430 to your computer and use it in GitHub Desktop.
C function pointer
#include <stdio.h>
int x2 (int n ) { return n*2; }
int x4 (int n ) { return n*4; }
int (*op[])(int) = {
x2,
x4
};
#define A(n) a##n
int main () {
int a1 = 1;
int a2 = 2;
int a3 = 3;
printf("%d\n", A(3));
printf("%d\n", A(2));
printf("%d\n", A(1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment