求教getchar的详细用法
#include<stdio.h>main()
{
char sex,sports,diet;
float myheight,maheight,faheight;
printf("are you a boy(b) or a girl(g)?");
scanf("%c",&sex);
printf("please input your mather'height--(cm):");
scanf("%f",&maheight);
printf("please input your father'height--(cm):");
scanf("%f",&faheight);
printf("do you like sports(y/n)?");
getchar();
scanf("%c",&sports);
printf("do you have a good habit of diet(y/n)?");
getchar();
scanf("%c",&diet);
if(sex=='b')
myheight=(maheight+faheight)*0.54;
else
myheight=(maheight+faheight)*0.5;
if(sports=='y')
myheight=myheight*1.102;
else
myheight=(faheight*0.923+maheight)*0.5;
if(diet=='y')
myheight=myheight*1.1015;
printf("your future height will be %f (cm)\n",myheight);
getch();
}
程序中的getchar为什么不可省略,getchar的详细用法及注意事项,请详细讲一下
谢谢