我在使用這段代碼的麻煩:串信相比,不兼容的參數
char myword[] = "ABC\0";
// for loop for length of array
for (int i = 0; i<strlen(myword); i++) {
if (strcmp(myword[i], 'A') == 0) {...
應該檢查是否是我的信件等於A.是否嘗試過進入ABC不同字母但錯誤:
Error: Argument of type "char" is incompatible with parameter of type "const char *" in "main.cpp"
不斷出現。
C不是C++ - 不要垃圾標籤。請發佈[MCVE]。 –
您的字符串長度爲5個字符,並帶有兩個'\ 0'字符。我猜這不是你想到的。 – chris
您正在使用strcmp來比較單個字符。 strcmp用於比較字符的數組或字符串 –