I was reading this: http://johnsantic.com/comp/state.html and having hard time comprehending this part:
void (*const state_table [MAX_STATES][MAX_EVENTS]) (void) = {
{ action_s1_e1, action_s1_e2 }, /* procedures for state 1 */
{ action_s2_e1, action_s2_e2 }, /* procedures for state 2 */
{ action_s3_e1, action_s3_e2 } /* procedures for state 3 */
};
Can someone please explain what is going on here?
It defines 2D array of pointers functions (return void).
state_table [MAX_STATES][MAX_EVENTS]means thatstate_tableis 2D array, and thevoid (*expression)(void)means thatexpressionis pointer to a function, that takes no arguments (this is the mean of(void)as argument list), and returnsvoid.The other lines just initializes the array.