我有問題。當我聲明'x'整數時,程序正常工作,但是當我刪除'x'時,它顯示出一個奇怪的結果。爲什麼定義'x'int(C)
#include <stdio.h>
#include <conio.h>
main()
{
int a,b,x;
char ras;
printf("Insert a: ");
scanf("%d", &a);
printf("Insert b: ");
scanf("%d", &b);
printf("Sum or multuply: (s/m)");
scanf("%s", &ras);
if (ras=='s')
{
printf("Sum is :%d", a+b);
}
else if (ras=='m')
{
printf("Multiply is :%d", a*b);
}
getch();
}
在聲明「int ** x **'中取走尾隨'**'。 – Leonardo
'scanf(「%s」,&ras);'應該是'scanf(「%c」,&ras);' –
@Leonardo我認爲他使用**作爲強調,這不在他的實際代碼中:) – rightfold