为什么这个键盘输入在C中不作为字符

为什么这个键盘输入在C中不作为字符,c,C,我真的很困惑,为什么当我为这段代码的字符值分配支付选项时,它并没有作为字符输入。我试图将我的代码更改为几个方法,但这些方法都不能解决我的问题 #include<stdio.h> int main(){ char Ptype; char Rtype; int noRoom; int noNight; int noRooms; float total; char ch; printf("Please enter the room type\n"); scanf("%c",&

我真的很困惑,为什么当我为这段代码的字符值分配支付选项时,它并没有作为字符输入。我试图将我的代码更改为几个方法,但这些方法都不能解决我的问题

#include<stdio.h>
int main(){

char Ptype;
char Rtype;
int noRoom;
int noNight;
int noRooms;

float total;
char ch;

printf("Please enter the room type\n");
scanf("%c",&Rtype);

if(Rtype =='D' || Rtype == 'd'){

    printf("Please Enter the no of night ");
    scanf("%d",&noNight);

    printf("Please Enter the no of room ");
    scanf("%d",&noRooms);

    printf("Please enter the paying method");
    scanf("%c",&Ptype); // input is not taking as char 

if(Ptype=='M' || Ptype == 'N'){

    total=noNight*5000;
    printf("%fTotal amount is", total );

    }

    else if (Rtype=='c' || Rtype == 'C'){

    total=noNight*5000*0.10;
    printf("%fTotal amount is", total);

   }}

   return 0;
   }
#包括
int main(){
字符类型;
字符类型;
内特诺鲁姆;
整夜;
国际诺鲁姆斯;
浮动总额;
char ch;
printf(“请输入房间类型\n”);
scanf(“%c”和&Rtype);
如果(Rtype=='D'| | Rtype=='D'){
printf(“请输入夜晚的编号”);
扫描频率(“%d”,不亮)(&noNight);
printf(“请输入房间号”);
扫描频率(“%d”、&noRooms);
printf(“请输入付款方式”);
scanf(“%c”,&Ptype);//输入不作为字符
如果(Ptype='M'| | Ptype=='N'){
总计=noNight*5000;
printf(“%f总金额为”,总计);
}
else if(Rtype=='c'| | Rtype=='c'){
总计=noNight*5000*0.10;
printf(“%f总金额为”,总计);
}}
返回0;
}
scanf中%c说明符前面的空格指示它跳过任意数量的空格。换句话说,从标准输入读取,直到并除非找到非空白字符或键盘中断

 scanf(" %c",&Ptype);