我是 C 的新手,并嘗試檢查回圈條件以在 Internet 上找到,但我得到了這個我無法解決的錯誤(沒有其他問題/答案有幫助):
void main() {
char* insert = malloc(30);
printf("Insert a Molecular Formula:\n");
gets(insert);
if (insert) {
for (int i = 0; insert[i] != '\0'; i ) {
}
} }
檢查時,我在 for 回圈內的 VS 中收到錯誤 6011 insert[i] != '\0'。我還沒有找到一個好的解決方法,我試過檢查 malloc 的回傳,if(!insert){ //above code here}
但這沒有幫助。提前致謝。
uj5u.com熱心網友回復:
錯誤 C6011 是警告,而不是錯誤,因此您的代碼將運行,但如果 Visual Studio 指示這些問題,處理這些問題也不錯。
要讓警告消失,請像這樣修復回圈:
if (insert)
{
for (int i = 0; insert[i] != '\0'; i ) {
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/417845.html
標籤:
上一篇:.tfignore路徑沒有被忽略
