小编Ali*_*ğuz的帖子

在C中定义另一个函数输入内的函数

我有一个具有函数指针输入的函数.我可以轻松地将函数名称作为输入.但我想知道是否可以将函数定义为输入.例如,我有这样的功能;

void exampleFunction ( void (*functionPointer)( void ) ) {
  codes
  ...
}
Run Code Online (Sandbox Code Playgroud)

我可以在括号内输入这样的输入吗?例如;

exampleFunction( void helloFunction ( void ) {
  printf("Hello");
} );
Run Code Online (Sandbox Code Playgroud)

它给出了像这样的编译错误,但有没有其他方法可以做到这一点?

c c++ function-pointers input function

5
推荐指数
1
解决办法
135
查看次数

标签 统计

c ×1

c++ ×1

function ×1

function-pointers ×1

input ×1