Quote Originally Posted by anduril462 View Post
Here's what your declaration of FunArray looks like to the compiler. Note, I added the parentheses in purple that you seem to have forgotten, or that the compiler filled in for you.
Code:
int (*FunArray1[8])(int);
FunArray is an array of 8 pointers to functions that take an int and return an int.

Here is the declaration of playPT1 you try to assign to your array:
Code:
void playPT1(void)
playPT1 is a function that takes nothing and returns nothing.

Notice how the purple and red parts don't match up between the two? For proper assignment, function pointers have to match parameter count and types as well as return type. You either need to make FunArray void-void:
Code:
void (*FunArray1[8])(void);
or make your playPT functions int-int:
Code:
int playPT1(int x)
Does it matter whether the functions that the array is pointing to return or take values? I wouldn't think so, so I made the the functions void-void.

What does the input to the functions have to do with its index on the array?

I thought "int (*FunArray1[8])(int);" took a value (funIndex) and returns an address, the the program goes to the function and when I type in "return;", it goes back to the main program? Am I wrong? ( I realize I probably am wrong about everything I've said).


Can I use the int "int (*FunArray1[8])(int funIndex);" (its declaration) like this:

*FunArray1[funIndex];

to go to the function I want, then, in the function put "return;" to go back to the main program?

So I guess this is where I am confused especially, why do I have to declare the array like this:
int (*FunArray1[8])(int funIndex);

When I am passing a parameter into the array (funIndex) within the []'s?

Could I declare the function like this:
int (*FunArray1[int funIndex = 8]; since the []'s is where I am passing the index right?