结构体数组初始化及定义位置疑问, 求大神指教!!! 感激。。。
可以全部初始化为0:
程序代码:#include<stdio.h>
#include<windows.h>
typedef struct{
int cy;
int fq;
}stColor;
int main()
{
typedef struct{
int price;
stColor color[7];
int style;
int size;
}stCoat;
stCoat mytest[10] = {0};
printf("%p,%p,%p,%p\n",&mytest[0].price, &mytest[0].color, &mytest[0].style, &mytest[0].size);
system("pause");
return 0;
}不能全部初始化0:
程序代码:#include<stdio.h>
#include<windows.h>
int main()
{
typedef struct{
int cy;
int fq;
}stColor;
typedef struct{
int price;
stColor color[7];
int style;
int size;
}stCoat;
stCoat mytest[10] = {0};
printf("%p,%p,%p,%p\n",&mytest[0].price, &mytest[0].color, &mytest[0].style, &mytest[0].size);
system("pause");
return 0;
}这两段代码中stCoat结构体里的stColor一次能初始化一次不能,为什么会这样?
[ 本帖最后由 lxsjzbd 于 2013-4-7 19:11 编辑 ]










顶一下,别沉了啊。。。