此问题已在此处有答案:
Why does scanf require &?(7个回答)
24天前关闭
#include <stdio.h>
int main(){
double Radius, Circumference, Area, Pi = 3.1416;
printf("Value of Radius:");
scanf("%lf",Radius);
Area = Pi * Radius * Radius;
Circumference = 2 * Pi * Radius;
printf("The area of the circle is %lf", Area);
printf("\nThe circumference of the circle is %lf", Circumference);
return 0;
}
我希望能得到周长和面积,只需要把半径代入。
1条答案
按热度按时间ttygqcqt1#
scanf
函数需要指针。你应该已经收到一个警告(启用警告!)编译此:
您还应该检查
scanf
的返回值,以确保它实际上读取了正确数量的值。