這裏發生了什麼問題?我收到錯誤Use of undeclared identifier 'answer'
while循環C編碼錯誤
這裏是我的代碼:
if (CalculatorChoice == 1) do {
int a;
int b;
int sum;
char answer;
printf ("You have choosen addition, please enter first number: ");
scanf("%d", &a);
printf ("Now please enter second number to addit: ");
scanf("%d", &b);
printf("The sum is: %d \n\n", sum = a+b);
printf("Do you want to go back to menupage? (y/n): ");
answer = getchar();
getchar();
} while(answer=='y');
'char答案;'必須在do-while之前定義。和'answer = getchar(); getchar();' - >'getchar();回答= getchar();' – BLUEPIXY
問題出自「while(answer =='y');」 :-( – SchnitteKing
另外'答案== 'y''! - >'回答=' y''或'答案== '?n'' – BLUEPIXY