R
Romeo Colacitti
Section "1.2.5 Structures and Unions" of the C Library Reference Guide
(http://www.acm.uiuc.edu/webmonkeys/book/c_guide/1.2.html#struct)
explains that it is possible to initilize elements of all structs of a
certain type by providing an initializer when declaring the template of
the struct.
I tried it on my compiler and it's complaining. This is taken from the
C Library Reference Guide:
struct my-structure {
int fred[5];
char wilma, betty;
float barny=1;
};
This defines the structure my-structure, but nothing has yet been done.
struct my-structure account1;
This creates account1 and it has all of the variables from
my-structure. account1.barny contains the value "1".
I tried this on my system, and it complained about the = 1. I must say
if this feature was possible it would be very good because a lot of
structs have flags and it would be nice to initialize them all to 1 or
0.
Can someone tell me if this is possible? I really suck at searching
through the C89/99 drafts to find answers, and can't find this on
google. thank you
(http://www.acm.uiuc.edu/webmonkeys/book/c_guide/1.2.html#struct)
explains that it is possible to initilize elements of all structs of a
certain type by providing an initializer when declaring the template of
the struct.
I tried it on my compiler and it's complaining. This is taken from the
C Library Reference Guide:
struct my-structure {
int fred[5];
char wilma, betty;
float barny=1;
};
This defines the structure my-structure, but nothing has yet been done.
struct my-structure account1;
This creates account1 and it has all of the variables from
my-structure. account1.barny contains the value "1".
I tried this on my system, and it complained about the = 1. I must say
if this feature was possible it would be very good because a lot of
structs have flags and it would be nice to initialize them all to 1 or
0.
Can someone tell me if this is possible? I really suck at searching
through the C89/99 drafts to find answers, and can't find this on
google. thank you