Created
December 24, 2011 06:25
-
-
Save 9re/1516551 to your computer and use it in GitHub Desktop.
ugly type declaration without typedef
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> | |
char * const func(int a, int b) { | |
static char * const str = "Yeah!"; | |
printf("%s a: %d, b: %d\n", __func__, a, b); | |
return str; | |
} | |
char * const (*func_getter(int a))(int, int) { | |
printf("%s a: %d\n", __func__, a); | |
return &func; | |
} | |
int main(int argc, char **argv) { | |
char * const (*(*ptr_func_getter)(int))(int, int) = &func_getter; | |
char * const (*ptr_func_arr[3])(int, int) = { | |
ptr_func_getter(4), | |
ptr_func_getter(5), | |
ptr_func_getter(6) | |
}; | |
for (int i = 0; i < 3; ++i) { | |
char * const (*p)(int, int) = ptr_func_arr[i]; | |
p(3, i); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment