#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
char ch;
printf("Enter value of a and b");
scanf("%d %d",&a,&b);
printf("Enter choice of operation");
scanf("%c",&ch);// **Here this statment is not able to receive my input***
switch(ch)
{
case '+':
c=a+b;
break;
case '-':
c=a-b;
break;
default:
printf("invalid");
break;
}
getch();
}
錯誤:在C題中掃描字符
scanf("%c",&ch);
// 下面這statment不能接受我的輸入 無法掃描用戶給定的輸入??????
感謝..
'scanf(「%c」,&ch)'會修復它。 – 2011-02-24 19:44:26