Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
https://www.cs.cf.ac.uk/Dave/C/node12.htmlPointers to functions are not as common as other pointer uses. However, one common use is in a passing pointers to a function as a parameter in a function call.
fnPtr[msg->type](msg);
/*--- State machine functions. ---*/
UI_16 standby(void);
UI_16 starting(void);
UI_16 running(void);
/*--- State Machine. ---*/
enum {STANDBY = 0, STARTING, RUNNING};
/*********************************************************************
* Function Name : main
* Description : Program entry point.
Initialise array of constant function pointers.
Initialise state machine to standby.
Execute state machine.
*********************************************************************/
SI_16 main(void)
{
UI_16 (*const Motor_State[])(void) = {standby, starting, running};
UI_16 State = STANDBY;
for(;;){
State = Motor_State[State](); /* call state function */
}
}
/*--- End of file. ---*/