c语言错误c2197是什么,C语言哪里错了?照着书敲的。求x1*x1+x1*x2

C语言错哪了?照着书敲的。求x1*x1+x1*x2

#include

double f1(double x)

{

return x*x;

}

double f2(double x,double y)

{

return x*y;

}

double fun(double a,double b)

{

double (*f)();

double r1,r2;

f=f1;

r1=(*f)(a);

f=f2;

r2=(*f)(a,b);

return r1+r2;

}

void main()

{

double x1,x2,r;

printf("请输入x1x2:");

scanf("%lf%lf",&x1,&x2);

r=fun(x1,x2);

printf("x1=%.2f,x2=%.2f,x1*x1+x1*x2=%.2f\n",x1,x2,r);

}

--------------------Configuration: P2256_16函数指针 - Win32 Debug--------------------

Compiling...

7.cpp

c:\users\acer\desktop\p2256_16函数指针\7.cpp(14) : error C2440: '=' : cannot convert from 'double (__cdecl *)(double)' to 'double (__cdecl *)(void)'

This conversion requires a reinterpret_cast, a C-style cast or function-style cast

c:\users\acer\desktop\p2256_16函数指针\7.cpp(15) : error C2197: 'double (__cdecl *)(void)' : too many actual parameters

c:\users\acer\desktop\p2256_16函数指针\7.cpp(16) : error C2440: '=' : cannot convert from 'double (__cdecl *)(double,double)' to 'double (__cdecl *)(void)'

This conversion requires a reinterpret_cast, a C-style cast or function-style cast

c:\users\acer\desktop\p2256_16函数指针\7.cpp(17) : error C2197: 'double (__cdecl *)(void)' : too many actual parameters

c:\users\acer\desktop\p2256_16函数指针\7.cpp(24) : error C2065: 'sanf' : undeclared identifier

执行 cl.exe 时出错.

P2256_16函数指针.exe - 1 error(s), 0 warning(s)

刚刚在百度提问说问题违规还被删了

173628145.gif

------解决思路----------------------

既然是C语言而不是C ,请楼主将你的源代码文件名后缀由.cpp改为.c

  • 0
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值