int类型*(*)(int *,int *(*)()) [英] type of int * (*) (int * , int * (*)())
本文介绍了int类型*(*)(int *,int *(*)())的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int *(*)(int *,int *(*)())
int * (*) (int * , int * (*)())
我想知道它是什么类型? ,有人可以举例说明使用这种类型的声明吗.
I'd like to know what type is it ? , can someone give an example of a declaration using this type.
任何帮助都会很棒.
谢谢.
推荐答案
它是指向返回int*
并接受int*
的函数的指针和指向返回int*
的函数的指针(并接受未定义数量的参数;查看评论).
It is a pointer to function that returns int*
and accepts int*
and pointer to function that returns int*
(and accepts undefined number of parameters; see comments).
一些例子(看起来不是很好,它只是构造为包含所提到的声明):
Some example (does not look very nice, it is just constructed to contain the mentioned declaration):
#include <stdio.h>
static int a = 10;
int* f1() {
return &a;
}
static int b;
int* f2(int *j, int*(*f)()) {
b = *j + *f();
// this is just for demonstrational purpose, such usage
// of global variable makes this function not thread-safe
return &b;
}
int main(int argc, char *argv[]) {
int * (*ptr1)();
int * (*ptr2) (int * , int * (*)());
ptr1 = f1;
ptr2 = f2;
int i = 42;
int *pi = ptr2(&i, ptr1);
printf("%d\n", *pi);
return 0;
}
// prints 52
这篇关于int类型*(*)(int *,int *(*)())的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文