int main(int argc, char *argv[])
{
char str1[][6]={"hello","world","apple"};
char* str2[3]={"hello","world","apple"};
printf("%d\n",sizeof(str1));//3*6=18
printf("%d\n",sizeof(str2));//3*4=12
printf("%s\n",*str1);
printf("%s\n",*(str1+1));
printf("%s\n",*(str1+2));
printf("%s\n",*str2);
printf("%s\n",*(str2+1));
printf("%s\n",*(str2+2));
return 0;
}
特别说明:str2这种字符数组定义更加灵活,且更节省内存空间!