我在尝试编译和运行时遇到错误,[链接器错误]未定义引用`scand'

时间:2015-04-11 10:31:25

标签: c scanf dev-c++


所以我正在使用Dev C ++创建一个程序,这是程序的工作原理:

允许用户输入以磅为单位的重量,然后您的程序将该值转换为千克和克。

允许用户以厘米为单位输入高度,然后程序将其转换为米,英尺和英寸。

我的Dev C ++代码

#include <stdio.h>
#define CENTIMETER 0.01
#define POUNDS 0.453592
int main (void) 
{
         float Pounds;
         float Kilograms;
         float Grams;
         float Centimeters;
         float Meters;
         float Feet;
         float Inches;

         printf("Please Enter your weight in Pounds : ");
         scanf("%f",&Pounds);
         Kilograms=Pounds*POUNDS;
         Grams=Kilograms*1000;
         printf(" Weight in kilograms is %.2f", Kilograms);
         printf(" Weight in grams is %.2f", Grams);
         printf("\n\n\n\n\n\nAnd ");
         printf("Please Enter your height in Centimeters: ");
         scand("%f",&Centimeters);
         Meters=Centimeters*CENTIMETER;
         Feet=Meters*3.28084;
         Inches=Feet*12;
         printf(" Height in Meters is %.2f", Meters);
         printf(" Height in Feet is %.2f", Feet);
         printf(" Height in Inches is %.2f", Inches);

         getch();
         return 0;
         }


问题是我无法保存,它说:

“[链接器错误]未定义引用`scand'”,
“ld返回1退出状态”

我很喜欢编程,所以我希望有人可以帮助我..

1 个答案:

答案 0 :(得分:1)

该代码包含拼写错误。在本声明中

scand("%f",&Centimeters);

应该有scanf而不是scand

scanf("%f",&Centimeters);