Created
January 23, 2013 14:05
-
-
Save wancw/4605980 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> | |
typedef void (*func_ptr_t)(int x, ...); | |
void foo(int x) { | |
printf("foo(%d)\n", x); | |
} | |
void bar(int x, int y, int z) { | |
printf("foo(%d, %d, %d)\n", x, y, z); | |
} | |
int main() { | |
func_ptr_t fptr; | |
fptr = (func_ptr_t) foo; | |
fptr(1,2); // foo(1) | |
fptr = (func_ptr_t) bar; | |
fptr(1,2); // bar(1,2,UNDEFINED) | |
fptr(1,2,3); // bar(1,2,3) | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment