首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

,请问几个关于指针与数组的有关问题,多谢

2012-06-14 
高手请进,请教几个关于指针与数组的问题,谢谢typedef struct{int aint bint c}MyDateMyDate aday,tday

高手请进,请教几个关于指针与数组的问题,谢谢
typedef struct{
int a;
int b;
int c;
}MyDate;

MyDate aday,tday;

MyDate date[]={aday,tday}; //为什么这里错了?
MyDate datee[]={{1,2,3},{4,5,6}}; //为什么这里对了?

char *x1="asdfgsa",*x2="qwrw";
char s1[]={*x1,*x2}; //为什么这里对了?
char s2[]={"as","wtqw"}; //为什么这里错了?

char s4[5][5]={"asf","adgf"}; //为什么这里对了?
char s3[][]={"asgsa","wetrw"}; //为什么这里错了?


[解决办法]
MyDate date[]={aday,tday}; //为什么这里错了?
MyDate datee[]={{1,2,3},{4,5,6}}; //为什么这里对了?

数组元素的类型是结构体类型
char *x1="asdfgsa",*x2="qwrw";
char s1[]={*x1,*x2}; //为什么这里对了?
char s2[]={"as","wtqw"}; //为什么这里错了?
数组元素 是char * 不是指针

char s4[5][5]={"asf","adgf"}; //为什么这里对了?
char s3[][]={"asgsa","wetrw"}; //为什么这里错了?
2维数组 行可以省略 列不能省 ,否则编译器 不知道数组的大小

热点排行