我是C語言的新手,我試著檢查了網上的回圈條件,但我得到了這個錯誤,我無法解決(沒有其他問題/答案是有幫助的):
void main() {
char* insert = malloc(30)。
printf("插入一個分子公式。
")。)
gets(insert)。
if (insert) {
for (int i = 0; insert[i] != ''/span>; i ) {
}
} }
當檢查insert[i] != ''時,我在VS的for-loop里面得到錯誤6011。
我還沒有找到好的解決方法,我試著檢查malloc的回傳,比如if(!insert){ //above code here}。
但這并沒有幫助。
謝謝你。
uj5u.com熱心網友回復:
錯誤C6011是一個警告,不是一個錯誤,所以你的代碼會運行,但是如果Visual Studio顯示這些問題,處理這些問題也不錯。
為了讓警告消失,請這樣修復你的回圈:
為了讓警告消失,請這樣修復你的回圈。
if (insert)
{
for (int i = 0; insert[i] != ' '; i ) {
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/317250.html
標籤:
