#include <stdio.h> typedef unsigned short UNSIGNED16; typedef unsigned char UNSIGNED8; typedef UNSIGNED16 (*DEMO_CYCLE)(void); static UNSIGNED16 lp_demo(void); static UNSIGNED16 ap_demo(void); static UNSIGNED16 md_demo(void); static UNSIGNED16 mixed_demo(void); DEMO_CYCLE p_demo_cycle = NULL; DEMO_CYCLE p_demo_cycle_group[4] = {lp_demo, ap_demo, md_demo, mixed_demo}; UNSIGNED8 demo_type; static UNSIGNED16 lp_demo(void) { printf("lp_demo执行这里\n"); return 0; } static UNSIGNED16 ap_demo(void) { printf("ap_demo执行这里\n"); return 0; } static UNSIGNED16 md_demo(void) { printf("md_demo执行这里\n"); return 0; } static UNSIGNED16 mixed_demo(void) { printf("mixed_demo执行这里\n"); return 0; } int main(int argc, char *argv[]) { UNSIGNED16 result = 0; printf("%d\n",demo_type); //获取函数地址 p_demo_cycle = p_demo_cycle_group[demo_type]; //利用函数地址调用函数 result = (*p_demo_cycle)(); return 0; }