setting initial values in struct template
From: Romeo Colacitti (wwromeo_at_gmail.com)
Date: 03/30/05
- Next message: Gancy: "Translate C++ to C"
- Previous message: Don: "Re: Retrieving a value from a void function."
- Next in thread: dot_at_dot.dot: "Re: setting initial values in struct template"
- Reply:(deleted message) dot_at_dot.dot: "Re: setting initial values in struct template"
- Reply: Keith Thompson: "Re: setting initial values in struct template"
- Reply: Krishanu Debnath: "Re: setting initial values in struct template"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Mar 2005 20:38:01 -0800
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
- Next message: Gancy: "Translate C++ to C"
- Previous message: Don: "Re: Retrieving a value from a void function."
- Next in thread: dot_at_dot.dot: "Re: setting initial values in struct template"
- Reply:(deleted message) dot_at_dot.dot: "Re: setting initial values in struct template"
- Reply: Keith Thompson: "Re: setting initial values in struct template"
- Reply: Krishanu Debnath: "Re: setting initial values in struct template"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]