In article <et**********@news.yaako.com>,
guoliang <po********@gmail.comwrote:
>hi:
in c,i use :
int a[5],b[5]={1,2,3,4,5};
struct {
int c[5];
}aaa,bbb;
bbb.c[0]=bbb.c[1]=bbb.c[2]=bbb.c[3]=bbb.c[4]=2;
1) a=b; //compile error;
2) aaa=bbb
1.what's differ between 1),2)?
One involves arrays, the other involves structs. Assigning structs is legal,
assigning arrays isn't.
>2.why i can't init bbb by bbb.c[5]={2,2,2,2,2};
Pick one of these:
struct { int c[5]; } aaa, bbb={.c={2,2,2,2,2}};
struct { int c[5]; } aaa, bbb={{2,2,2,2,2}};
struct { int c[5]; } aaa, bbb={2,2,2,2,2};
struct { int c[5]; } aaa, bbb;
memcpy(&bbb.c, (int[5]){2,2,2,2,2});
struct foo { int c[5]; } aaa, bbb;
bbb=(struct foo){.c={2,2,2,2,2}};
struct foo { int c[5]; } aaa, bbb;
bbb=(struct foo){{2,2,2,2,2}};
--
Alan Curry
pa****@world.std.com