【发布时间】:2021-06-25 15:10:07
【问题描述】:
我有一个函数指针数组
typedef uint32_t (*test) ( void );
static const test tests[] =
{
test_1 ,
test_2 ,
test_3 ,
test_4 ,
test_5 ,
};
我想返回一个指向上述函数指针数组的指针。谁能帮我做。
谢谢!
【问题讨论】:
我有一个函数指针数组
typedef uint32_t (*test) ( void );
static const test tests[] =
{
test_1 ,
test_2 ,
test_3 ,
test_4 ,
test_5 ,
};
我想返回一个指向上述函数指针数组的指针。谁能帮我做。
谢谢!
【问题讨论】:
我们应该可以写const test *get_tests(void);。在这里我们记住,数组的类型可以转换为指向第一个元素的指针的类型,并且这样做很简单。
善用typedef作为函数指针,让你的生活更轻松。
【讨论】: