Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | ArifulHossain tuhin <etothepowerpi@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: passing a pointer to initialized structrue in a function |
| Date | 2012-03-02 07:44 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <31199210.506.1330703048396.JavaMail.geo-discussion-forums@pbls8> (permalink) |
| References | <30546693.434.1330702765903.JavaMail.geo-discussion-forums@pbfa4> |
On Friday, March 2, 2012 9:39:25 PM UTC+6, ArifulHossain tuhin 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?
Sorry for dual posting. first one was not shown for a while. so i thought i did something wrong and posted again. group admin can delete one.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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