#include "stdio.h" void (*tprint_p)(void); void tprint(void) { printf("hello world\r\n"); } void main(void) { tprint_p = tprint; tprint_p(); (*tprint_p)(); printf("tprint_p: 0x%x\r\n", (int)tprint_p); printf("(*tprint_p): 0x%x\r\n", (int)(*tprint_p)); int aa = 12; int *tint = &aa; printf("tint: 0x%x\r\n", (int)tint); printf("(*tint): 0x%x\r\n", (int)(*tint)); }
类比整型指针变量,取指针内容是存储的值,而函数指针取其存储的值就是函数,也就还是函数地址。