标签:
#include <stdio.h>
//指针数组练习
int main1(void)
{
//int a[10];
char* arry[3] = {"hello", "world", "itcast"};
//char arry[3][20] = {"hello", "world", "itcast"};
//char *str = "hello";
int i;
printf("%d\n", sizeof(arry));
for (i = 0; i < 3; i++)
printf("%p\t%s\n", arry[i], arry[i]);
return 0;
}
//指针数组易犯错误
int main(void)
{
//int a[10];
char* arry[3]; //arry[0] => 0x0
//char arry[3][20] = {"hello", "world", "itcast"};
//char *str = "hello";
int i;
for (i = 0; i < 3; i++)
scanf("%s", arry[i]); //使用二维数组申请字符串存储空间
for (i = 0; i < 3; i++)
printf("%s", arry[i]);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/zhuyaguang/p/4831193.html