空數組我在C以下代碼:如何檢查是否使用C
int i = 0;
char delims[] = " \n";
char *result = NULL;
char * results[10];
result = strtok(cmdStr, delims);
while(result != NULL)
{
results[i] = result;
i++;
result = strtok(NULL, " \n");
}
if(!results[1])
{
printf("Please insert the second parameter...\n");
}
else
{
...
}
它始終執行即使results[1]
是空的else
條件。我試過results[1] == NULL
但沒有成功。
我該如何檢查它是否爲空?
具體實施方式,以檢查是否一個字符數組爲空(http://stackoverflow.com/questions/1793867/best檢查字符數組是否爲空) – ljedrz