Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef void (*VoidVoid)( void );
- typedef void (*VoidInt)( int );
- typedef int (*IntInt)( int );
- void func1( void );
- void func2( int );
- int func3( int );
- int main(void)
- {
- VoidVoid tab[3] = { func1, (VoidVoid)func2, (VoidVoid)func3 };
- int choice = 1;
- switch(choice)
- {
- case 0:
- {
- VoidVoid func;
- func = tab[choice];
- func();
- // lub tab[choice]();
- break;
- }
- case 1:
- {
- VoidInt func;
- func = (VoidInt)tab[choice];
- func(5);
- break;
- }
- case 2:
- {
- IntInt func;
- func = (IntInt)tab[choice];
- func(5);
- break;
- }
- default:
- {
- break;
- }
- }
- return 0;
- }
- void func1( void )
- {
- puts("func1");
- }
- void func2( int a )
- {
- puts("func2");
- }
- int func3( int b)
- {
- puts("func3");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement