如何刪除這些警告?如何在刪除c字符串時刪除這些警告
char foo[10], msg2[100];
int k;
for (k = 0; foo[k] != NULL; k++) //comparison between pointer and integer
msg2[k] = NULL; //assignment makes integer from pointer without a cast
謝謝。
如何刪除這些警告?如何在刪除c字符串時刪除這些警告
char foo[10], msg2[100];
int k;
for (k = 0; foo[k] != NULL; k++) //comparison between pointer and integer
msg2[k] = NULL; //assignment makes integer from pointer without a cast
謝謝。
警告是正確的,您使用NULL是錯誤的。
NULL指的是指針,而不是string nul-terminator。
在代碼中使用零而不是NULL,在兩個位置。 如果你想要一個特殊的零,你可以使用'\ 0',但那是多餘的。
什麼是foo和MSG 2的類型? – 2010-05-31 16:36:24
foo和msg2是如何聲明的? – 2010-05-31 16:36:37
如何顯示foo和msg2的聲明? (哇 - 3秒30秒:)) – Arkadiy 2010-05-31 16:36:53