Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdlib.h>
- #include<stdio.h>
- #include<string.h>
- #include<stdbool.h>
- char* f1(int a) {
- char* str = (char*) calloc(15, sizeof(char));
- sprintf(str, "%d", a);
- return str;
- }
- char* f2(int a, int b) {
- char* str = (char*) calloc(15, sizeof(char));
- sprintf(str, "%d", a + b);
- return str;
- }
- char* (*fun_p[])() = {&f1, &f2};
- int main(void) {
- int a = 1, b = 6;
- char* f1 = fun_p[0](a);
- char* f2 = fun_p[1](a, b);
- printf("%s\n%s\n", f1, f2);
- free(f1); free(f2);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement