我在C中創建了小代碼來測試一些東西。我認爲如果我寫0,我會收到輸出ABC。但我不能離開這個循環。請幫幫我。謝謝。不能離開循環
#include<stdio.h>
#include<stdlib.h>
int main()
{
int x;
while(1)
{
printf("Enter number\n");
scanf("%d",&x);
if(x=0)
goto stop;
}
stop:
printf("ABC");
return 0;
}
'if(x = 0)'是分配,而不是比較。另外,不要「停下來......」......只是「休息」; – indiv 2014-10-31 01:13:55
在你的'if'中使用'=='而不是'=' – Dmitri 2014-10-31 01:14:01
請不要使用'goto',你可以''break'退出循環 – 2014-10-31 01:15:48