linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@gnu.org>
To: Vadiraj <vadiraj.cs@gmail.com>
Cc: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: Re: initializing a struct
Date: Fri, 01 Jul 2011 13:58:06 -0400	[thread overview]
Message-ID: <1309543086.3374.1.camel@offbook> (raw)
In-Reply-To: <BANLkTikvCRn1mdCosk=-Bm8EqDamE5FtpQ@mail.gmail.com>

On Thu, 2011-06-30 at 15:48 +0530, Vadiraj wrote:
> Hey Guys,
>  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] ? What's the best practice?

This kind of initialization is done with memset(), so can use 0s to
avoid random data.

      parent reply	other threads:[~2011-07-01 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BANLkTimgJN2_SH+_mvkckZKBefCLN6aM=g@mail.gmail.com>
2011-06-30 10:18 ` initializing a struct Vadiraj
2011-06-30 11:03   ` Michal Nazarewicz
2011-07-01 17:58   ` Davidlohr Bueso [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1309543086.3374.1.camel@offbook \
    --to=dave@gnu.org \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=vadiraj.cs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).