【发布时间】:2014-09-25 03:17:30
【问题描述】:
我是 C 新手,所以我在使用 scanf() 时遇到了一些麻烦。
#include <stdio.h>
#include <stdlib.h>
int main()
{
int height;
int weight;
printf("Enter height in inches:\n");
scanf("%d", &height);
printf("Enter weight in pounds:\n");
scanf("%d", &weight);
printf("You are %d inches tall and weigh %d pounds.", height, weight);
return 0;
}
我很确定这是正确的语法,但是当我运行它时,它显示一个空白屏幕,在我输入 2 个数字后它显示:
64
120
以英寸为单位输入高度:
以磅为单位输入体重:
你身高 64 英寸,体重 120 磅。
根据一些教程,它应该在我输入第一个数字之前显示“以英寸为单位输入身高:”,在我输入第二个数字之前显示“以磅为单位输入体重:”。请帮帮我!
我正在使用 Eclipse 编写我的程序,并使用 MinGW 作为编译器(如果相关)。
【问题讨论】:
-
您的症状与您的代码不符