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


Groups > comp.lang.c > #18110

passing a pointer to initialized structrue in a function

From ArifulHossain tuhin <etothepowerpi@gmail.com>
Newsgroups comp.lang.c
Subject passing a pointer to initialized structrue in a function
Date 2012-03-02 07:39 -0800
Organization http://groups.google.com
Message-ID <30546693.434.1330702765903.JavaMail.geo-discussion-forums@pbfa4> (permalink)

Show all headers | View raw


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?

Back to comp.lang.c | Previous | Next — Next 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