//Your typedef struct
typedef struct _selection
{
char prompt[MAX_PROMPT_LEN];
int (*function)(int);
int fn_arg;
} SELECTION;
SELECTION mySel;
//various func with same return value and passing parameters
// like "pointer to a function"
int foo1(int a)
{
...
...
}
int foo2(int a)
{
...
...
}
int foo3(int a)
{
...
...
}
// two functions that make the same thing
void Func(int val)
{
for(int i=0; i<1000; i++) {
switch(val) {
case 1:
foo1(val);
break;
case 2:
foo2(val);
break;
case 3:
foo3(val);
break;
}
}
}
void BetterFunc(int val)
{
switch(val) {
case 1:
mySel.function = foo1;
break;
case 2:
mySel.function = foo2;
break;
case 3:
mySel.function = foo3;
break;
}
for(int i=0; i<1000; i++)
mySel.function(val);
}