c - How do you declare multiple function pointers in a single line without typedeffing? -
more of matter of curiosity anything. want know if it's possible declare multiple function pointers in line, like:
int = 1, b = 2;
with function pointers? without having resort typedef
.
i've tried void (*foo = null, *bar = null)(int)
. unsurprisingly, didn't work.
try follows:
void (*a)(int), (*b)(int); void test(int n) { printf("%d\n", n); } int main() { = null; = test; a(1); b = test; b(2); return 0; }
edit:
another form array of function pointers:
void (*fun[2])(int) = {null, null}; void test(int n) { printf("%d\n",n); } int main() { fun[0] = null; fun[0] = test; fun[0](1); fun[1] = test; fun[1](2); }
Comments
Post a Comment