Flash Gordon wrote:
[color=blue]
> Christian Christmann wrote:[color=green]
> > Hi,
> >
> > a question on local structs:
> >
> > Usually, when a local variable is used without initialization,
> > it might hold any value. According to C99, does this rule
> > also apply to elements of local structs?
> >
> >[/color][/color]
Is that the case with arrays or structs ???
Can you provide any authentic justification what you said. I dont agree
to it.
As the scope is local and the memory is allocted on the stack, will not
be initialised to zero.
Cheers,
Sandeepksinha.
[color=blue][color=green]
> > int main( void )
> > {
> > struct type {
> > int a;
> > int b;
> > int c;
> > } myStruct = { .b = 100 };
> > return 0;
> > }
> >
> >
> > Here, struct elements myStruct.a and myStruct.c are not
> > explicitely initialized. Do they contain an undefined value
> > or are they implicitely assign the value 0?[/color]
>
> If you initialise any part of a structure then the entire structure is
> initialised. The parts you don't initialise are set to an appropriate 0
> (including pointers being set to null).
> --
> Flash Gordon, living in interesting times.
> Web site -
http://home.flash-gordon.me.uk/
> comp.lang.c posting guidelines and intro:
>
http://clc-wiki.net/wiki/Intro_to_clc[/color]