I was demonstrating to a learning colleague how to use function pointers and how he could have an array of them. I put down the following code so that he could do indexed dispatch:
typedef void (*VoidFunction)();
VoidFunction functions[] =
{editProgramName,
editProgramLength,
editProgramCycles,
editProgramNumberOfSets,
editProgramEditSets,
editProgramSave,
editProgramCancel};
// now dispatch
functions[scroll.arrayFocusIndex]();
And then he asked... "How do I do it without the typedef?" To which I found after trying various things that seemed like they might work, I didn't have a clue to do. All the google hits I found always seemed to use a typedef. Is there a way to do it inline without the typedef of the function pointer?
void (*functions[])() = {...