code.club

 找回密碼
 立即註冊
搜索
查看: 6913|回復: 0

C語言中指標使用時機的問題?

[複製鏈接]
發表於 2014-6-25 15:25:57 | 顯示全部樓層 |閱讀模式
這是書上的範例,用一個字串二維陣列,然後輸入前面的顏色單字,出現後面的顏色意義。程式碼如下:

#include <stdio.h>
#include <string.h>

char *p[][2]={
"red","hot",
"green","peace",
"blue","suck",
"yellow","bright",
"white","pure",
"",""};

int main(void){
int x;
char color[90];
printf("enter a color:\n");
gets(color);
for(x=0;*p[x][0];x++)
{if (!strcmp(p[x][0],color))
printf("%s is %s.",color,p[x][1]);
}
return 0;
}


搞不懂的就是為何前面藍字部份是可以用指標*p[][],而紅字部份則沒有指標*的符號?
我有試著把它們加上指標符號,結果是錯的。那請問一下,後面為何不用指標符號?

thanks
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

小黑屋|手機版|Archiver|code.club  

GMT+8, 2024-4-19 02:12 , Processed in 0.095668 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表