#include<stdio.h>int main(){goto state;state ;printf("let's play a game");char c;c =getchar();fflush(stdin);}--------------------配置: mingw5 - CUI Debug, 編譯器類型: MinGW--------------------檢查文件依賴性...正在編譯 C:\Users\hust\Documents\C-Free\Temp\未命名1.cpp...[Error] C:\Users\hust\Documents\C-Free\Temp\未命名1.cpp:5: error: `state' was not declared in this scope[Error] C:\Users\hust\Documents\C-Free\Temp\未命名1.cpp:4: error: label `state' used but not defined[Warning] C:\Users\hust\Documents\C-Free\Temp\未命名1.cpp:11:2: warning: no newline at end of file構(gòu)建中止 未命名1: 2 個錯誤, 1 個警告
3 回答

至尊寶的傳說
TA貢獻(xiàn)1789條經(jīng)驗 獲得超10個贊
標(biāo)簽要使用冒號,而不是分號,
1 | state: // <-- 這里是冒號 |
另外,goto語句會破壞程序結(jié)構(gòu)性,盡量避免使用。

ibeautiful
TA貢獻(xiàn)1993條經(jīng)驗 獲得超6個贊
#include<stdio.h>
int main()
{
goto state;
state ://用冒號
printf("let's play a game");
char c;
c =getchar();
fflush(stdin);
}
//goto盡量不要用

慕俠2389804
TA貢獻(xiàn)1719條經(jīng)驗 獲得超6個贊
在軟件設(shè)計的過程中有一天就是盡量不用goto語句,有極大的不可控性,所以建議趁早放棄它,養(yǎng)成好習(xí)慣用for 和while循環(huán)簡練易懂,你的state沒有定義
- 3 回答
- 0 關(guān)注
- 215 瀏覽
添加回答
舉報
0/150
提交
取消