Calling function using input

Hello guys,
I want to call a certain function based on an input of the user, for example
I declare a int Num;
then I have multiple versions of a function named Function1(), Function2(), ..FunctionN(),
Hence the user Inputs a number called Num ,
lets say the user inputs 3
Then I want to call Function3()

How can I do that ??
1
2
3
4
5
6
7
8
if(Num==1)
function1();
else if(Num==2)
fucntion2();
.
.
.
.
If the functions have the same prototype you could use an array of functions.
Last edited on
if not, a switch/case would be easier on the eyes than an if/else if/else if... sequence.
Topic archived. No new replies allowed.