Re: initializing a struct
"Michal Nazarewicz" <[email protected]> Thu, 30 Jun 2011 13:03:26 +0200
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <op.vxvyb01k3l0zgt@mnazarewicz-glaptop> |
On Thu, 30 Jun 2011 12:18:25 +0200, Vadiraj <[email protected]> wrote: > I'm stuck with logical reason for initializing a struct variable. Please > help.. > Consider a struct defined this way.. > struct foo { > int a; > char *ptr; > }; > in my function I declare a local variable of this struct. > void bar() > { > struct foo local_var[10]; > ... > ... > } > do you suspect a initialization issue? do we need to initialize the > local array local_var[10] ? Yes. The array has random data. > What's the best practice? Uh? Initialise it if you need. -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michal "mina86" Nazarewicz (o o) ooo +-----<email/xmpp: [email protected]>-----ooO--(_)--Ooo--