在下面的代码。为什么这个程序没有显示任何错误?
- 我已经定义函数原型与定义以及在函数调用我已经使用一个参数没有参数
- 。
我想知道为什么我没有得到任何错误?
# include <stdio.h>
float circle(); /* no parameter*/
int main()
{
float area;
int radius =2;
area=circle(radius);
printf("%f \n",area);
return 0;
}
float circle(r) /* with one parameter even no parameter type */
{
float a;
a=3.14*r*r;
return (a);
}
不要硬编码PI。使用math.h中的M_PI。编辑:其实我不认为这是标准C.所以先检查。 – Bathsheba