调用一个结构指针函数是什么意思啊?函数名字就是结构体指针

例如这个struct student * search(struct student * s,int n)
这里调用struct student * search这个函数是什么意思?该怎样来理解呢?

struct student (* search)(struct student * s,int n)
一个指向结构体的函数指针类似
int(* p)(int a,int b )
struct student是类型类似int
参数是struct student 型的指针 和整型的n
调用这个结构体函数指针可以获得被调用函数端口地址常量追问

怎么能获得被调用函数端口地址常量呢?不是很明白

追答

比如double (*p)(double)=sin 就可以获得sin函数的地址常量

追问

不好意思,您能不能详细解答一下,有点迷糊了

追答

double (*p)(double)=sin就是把sin函数的端口地址赋给了p
p就可以当成SIN使用比如sin(0)=p(0)

温馨提示:答案为网友推荐,仅供参考
第1个回答  2019-04-12
返回的是结构体的指针,不是函数指针
你的create函数内部给结构体指针申请了一个sizeof(...)大小的空间,在主函数里用同样类型的结构体指针接收
相似回答