Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #18121

Re: passing a pointer to initialized structrue in a function

From cri@tiac.net (Richard Harter)
Newsgroups comp.lang.c
Subject Re: passing a pointer to initialized structrue in a function
Date 2012-03-02 19:40 +0000
Message-ID <4f5121d1.1255680892@text.giganews.com> (permalink)
References <30546693.434.1330702765903.JavaMail.geo-discussion-forums@pbfa4>

Show all headers | View raw


On Fri, 2 Mar 2012 07:39:25 -0800 (PST), ArifulHossain tuhin
<etothepowerpi@gmail.com> wrote:

>I have this structure like following :
>
>typedef struct{
>char static_data[10];
>int a;
>int b;
>} my_ds;
>
>i have initialized it like following:
>
>my_ds * ds = (my_ds *)malloc(sizeof(my_ds));
>memmove(my_ds->static_data, buf, len);
>ds->a = c;
>ds->b = d;
>
>and passed it in a function:
>
>int my_fun(void ** data);
>my_fun((void *)&ds);
>
>what happens inside my_fun, the first field, static[10] is initialized correctly but other two values are zero. What am i missing here?

Possibly that c and d are zero.  You need to show us the code that
gives them values.

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

passing a pointer to initialized structrue in a function ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-03-02 07:39 -0800
  Re: passing a pointer to initialized structrue in a function ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-03-02 07:44 -0800
    Re: passing a pointer to initialized structrue in a function James Kuyper <jameskuyper@verizon.net> - 2012-03-02 11:26 -0500
  Re: passing a pointer to initialized structrue in a function James Kuyper <jameskuyper@verizon.net> - 2012-03-02 11:45 -0500
    Re: passing a pointer to initialized structrue in a function James Kuyper <jameskuyper@verizon.net> - 2012-03-02 11:47 -0500
    Re: passing a pointer to initialized structrue in a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-03-02 17:02 +0000
      Re: passing a pointer to initialized structrue in a function James Kuyper <jameskuyper@verizon.net> - 2012-03-02 13:53 -0500
  Re: passing a pointer to initialized structrue in a function Ike Naar <ike@iceland.freeshell.org> - 2012-03-02 17:25 +0000
  Re: passing a pointer to initialized structrue in a function cri@tiac.net (Richard Harter) - 2012-03-02 19:40 +0000

csiph-web