OK.
Now I've tried to implement the parameters, based on the previous version.
Next I'll try the version proposed by Elysia.
Code:
// Program to demonstrate
// array of functions
#include<stdio.h>
// -- FUNCTION PROTOTYPES --
void func1(char, char);
void func2(char, char);
void func3(char, char);
void func4(char, char);
void func5(char, char);
// -- ENDS --
int main(void)
{
// notice the prototype
void (*ptr[5])(char, char);
// arrays are made to point
// at the respective functions
ptr[0]=&func1;
ptr[1]=&func2;
ptr[2]=&func3;
ptr[3]=&func4;
ptr[4]=&func5;
// now the array elements
// point to different functions
// which are called just like
// we access the elements of
// an array
for(int i=0;i<5;i++)
ptr[i]('A',' ');
return 0;
}
// -- FUNCTIONS DEFINITION --
void func1(char token, char times)
{
printf("Called Func1!\n");
printf("Token = \'%c\' - to repeat %d times\n",token,times);
}
void func2(char token, char times)
{
printf("Called Func2!\n");
printf("Token = \'%c\' - to repeat %d times incremented by 1\n",token,times);
}
void func3(char token, char times)
{
printf("Called Func3!\n");
printf("Token = \'%c\' - to repeat %d times doubled\n",token,times);
}
void func4(char token, char times )
{
printf("Called Func4!\n");
printf("Token = \'%c\' - to repeat %d times doubled except the last time\n",token,times);
}
void func5(char token, char times)
{
printf("Called Func5!\n");
printf("Token = \'%c\' - to repeat %d times tripled\n",token,times);
}
and the output:
Code:
Called Func1!
Token = 'A' - to repeat 32 times
Called Func2!
Token = 'A' - to repeat 32 times incremented by 1
Called Func3!
Token = 'A' - to repeat 32 times doubled
Called Func4!
Token = 'A' - to repeat 32 times doubled except the last time
Called Func5!
Token = 'A' - to repeat 32 times tripled
Press any key to continue...