#include <stdio.h>
#include <locale.h>
char *Weekdays[] = {
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};
void printWeekday()
{
char **ptr=Weekdays;
int i=0;
printf("%p\n",i,&Weekdays[0]);
printf("%p\n",i,&ptr);
for(i=0;i<7;i++){
printf("i=%d:%s\n",i,*ptr);
ptr++;
}
printf("\n");
}
char *Weekdays2[][2] = {
{"Monday", "1"},
{"Tuesday", "2"},
{"Wednesday", "3"},
{"Thursday", "4"},
{"Friday", "5"},
{"Saturday", "6"},
{"Sunday", "7"}
};
void printWeekday2()
{
char **ptr=&Weekdays2[0][0];
int i=0;
printf("%p\n",i,&Weekdays[0]);
printf("%p\n",i,&ptr);
for(i=0;i<7;i++){
printf("i=%d:%s \t",i,*ptr);
ptr++;
printf("%s\n",*ptr);
ptr++;
}
printf("\n");
}
输出结果为:
linxuan__ ../usrAppInit.c 43
0x0
0x0
i=0:Monday 1
i=1:Tuesday 2
i=2:Wednesday 3
i=3:Thursday 4
i=4:Friday 5
i=5:Saturday 6
i=6:Sunday 7
->