引用:
作者: yumi
函数原型:
int strcmp(const char *s1,const char *s2)
strcmp(*p[x][0],color)是不允许的转换
|
不太了解?
我目前學到的strcmp是strcmp(str_1,str_2);裡面並不是用指標,所以本題的{if (!strcmp(p[x][0],color))其中的p而非*p是因為無法用*而拿掉嗎?
再來就是最後的printf("%s is %s.",color,p[x][1]); 為何不寫成printf("%s is %s.",color,
*p[x][1]);呢?
而且我發現在(!strcmp(p[x][0],color)中如果寫成(!strcmp(p[x][0],
&color)也是可以的,why?
還有,為何這個char *p[][2]要在int main(void)的外面定義呢?我有試著把它移到main函數裡面來,答案似乎都一樣正確。