A simple example is this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void myHello(void);
void myGoodBye(void);
int main(void){
//create framework for function table
struct myFunctionTable{
char *myName;
void (*myFunction)(void);
};
//make function table, aka array
myFunctionTable FunctionTable[]={{"Hello", &myHello}, {"GoodBye", &myGoodBye}};
char myAnswer[10];
printf("Which function to run?");
scanf("%s", myAnswer);
//find and run function
for(int i = 0; i < (sizeof(FunctionTable) / sizeof(myFunctionTable));i++){
if(strcmp(FunctionTable[i].myName,myAnswer)==0){
FunctionTable[i].myFunction ();
break;
}
}
getchar();
getchar();
return (0);
}
//Implement functions
void myHello(void){
printf("Hello World\n");
}
void myGoodBye(void){
printf("GoodBye World\n");
}
Also Salem posted a C++ version a couple of days ago. If you look around on the net you will be able to find many solutions to this which include hash and jump table implementations.
EDIT: In fact Salem gave you this answer a couple of days ago on the C++ board.