剛開始學時遇到一個問題,如下代碼:
#include
int main()
...{
char a,b;
printf("Please input the first character:");
scanf("%c", &a);
printf("Please input the second character:");
scanf("%c", &b);
printf("The two characters are %c, %c", a, b);
return 0;
}
程序運行結果如下:
而下面這段程序卻可以正常運行:
#include
int main()
...{
char a;
int b;
printf("Please input the first character:");
scanf("%c", &a);
printf("Please input the second integer:");
scanf("%d", &b);
printf("The two characters are %c, %d", a, b);
return 0;
}
運行結果如下: