> warning: comparison between pointer and integer
當我嘗試編譯以下代碼時,出現上述錯誤。我意識到這個問題經常被問到,而且我確實發現了很多幫助過我的源代碼,但我並不是想用#define和argv []找到一個。道歉,如果這是重複的,儘管如此。使用#define和argv指針和整數警告之間的比較[]
#include <stdio.h>
#define MINBOUND 5
#define MAXBOUND 10
int main (int argc, char *argv[]){
if (argc > 1){
if (MINBOUND <= *argv[1] <= MAXBOUND){
printf("arg within bound\n");
}
else {
printf("arg outside bound\n");
}
else {
printf("arg missing\n");
}
return (0);
}
'MINBOUND <= * argv [1] <= MAXBOUND' - 你在哪裏見過這樣的語法? –
'else {' - >'} else {' – RoiHatam
老實說,我只是在這裏翩翩起舞。原來我比我最初以爲我會更加生疏 –