我在尝试编译和 运行、[链接器错误] 未定义对 `scand' 的引用时遇到错误
i get Error while trying to compile and Run, [Linker error] undefined reference to `scand'
所以我正在使用 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 个退出状态”
我是编程新手,所以我希望有人能帮助我..
代码中有错字。在这个声明中
scand("%f",&Centimeters);
应该有 scanf
而不是 scand
。
scanf("%f",&Centimeters);
所以我正在使用 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 个退出状态”
我是编程新手,所以我希望有人能帮助我..
代码中有错字。在这个声明中
scand("%f",&Centimeters);
应该有 scanf
而不是 scand
。
scanf("%f",&Centimeters);