vscode 中 scanf 函数无法运行,编译时可执行文件生成终止,已勾选RunInTerminal
#include <stdio.h>
int main(void)
{
float weight,value;
//假设白金的价格为每(金衡)盎司¥1700,单位换算机制详见P34
value=1700*weight*14.5833;
printf("Are you worth you weight in platinum?\n");
printf("let's check it out.\n");
printf("Please enter your weight in pounds.\n");
//新函数scanf:用于获取用户输入
getchar();
scanf_s("%f",&weight);
getchar();
printf("So your weight in platinum is worth $%.2f.\n",value);
printf("You are easily worth that! If platinum prices drop,\n");
printf("eat more to maintain your value.\n");
return 0;
}