This question asks about a finite state machine with 100 states and each state having 100 events, and then does a brief comparison of using an if-else, switch statement, or function pointers to implement the state machine.
My question is: if using function pointers, how would the function pointers be appropriately set? With an if-else or a switch statement (in which case, would function pointers be more of a hybrid solution)? Or is there another way this is commonly done?
You could do something like below:
Each state function should populate the next_state pointer. Also, you can modify the function pointers to take input arguments.