c - 错误: invalid type argument of 'unary *' (have 'int' )|

标签 c function pointers

#include <stdio.h>
int _area(), _vol(), (*fnptr)();// declare the functions and the function pointer here

_area(a,b)
int a, b;
{
    return (a*b); //The return value of _area after parameters are passed to it
}
_vol(fnptr,c) //engaging the function pointer as a parameter
int c;
{
    fnptr = _area(); //initializing the function pointer to function _area
    int k = (*fnptr)(8,9); // error occurs here
    return (k*c);
}

编译产生错误,

:error: invalid type argument of 'unary *' (have 'int')

最佳答案

**int k = (*fnptr)(8,9);** should be int **k = (*fnptr)(8,9);

关于c - 错误: invalid type argument of 'unary *' (have 'int' )|,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20608186/

相关文章:

c++ - 指向 vector 项的指针——在 Windows 上

c - 在 C 中使用数组的垃圾值

C 循环编程考试

c - 解析数学表达式

c - 从csv文件读取并分成变量

Python函数调用不同?

c - 冲洗替代品

javascript - 在react-native功能组件中哪里实现初始化代码

编写多个函数的 Pythonic 方式?

c - 局部变量到指针的转换