From: gumbold <gumbold@bonbon.net>
To: Glynn Clements <glynn@gclements.plus.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: data structure question
Date: Mon, 16 May 2005 21:31:56 +0300 [thread overview]
Message-ID: <4288E71C.2060400@bonbon.net> (raw)
In-Reply-To: <17032.48134.349409.976254@gargle.gargle.HOWL>
Glynn Clements wrote:
>gumbold wrote:
>
>
>
>>So char abc[0] actualy pointer to chat?
>>
>>
>
>No, it's an array of char.
>
>
>
>>It should be 4 byte long on x86. I can't see it with sizeof.
>>
>>
>
>It's zero bytes long.
>
>If you had:
>
> struct abc {
> __u16 a;
> __u16 b;
> char abc[4];
> };
>
>then sizeof(struct abc) would be 8 and the offset of abc from the
>beginning of the structure would be 4.
>
>With:
>
> struct abc {
> __u16 a;
> __u16 b;
> char abc[0];
> };
>
>sizeof(struct abc) would be 4 and the offset of abc from the beginning
>of the structure would still be 4 (i.e. p->abc refers to the first
>byte after the structure).
>
>
>
I understand. But if you doing `p->abc = (char *)malloc(111)' so you
copy 4 bytes to the place
started from p->abc, but it is out of struct abc memory (it is only 4
byte). Should be error?
next prev parent reply other threads:[~2005-05-16 18:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-15 9:32 data structure question gumbold
2005-05-15 11:02 ` Glynn Clements
2005-05-15 11:24 ` gumbold
2005-05-15 14:23 ` Glynn Clements
2005-05-16 4:00 ` gumbold
2005-05-16 15:28 ` Glynn Clements
2005-05-16 18:31 ` gumbold [this message]
2005-05-17 7:36 ` Glynn Clements
2005-05-16 19:07 ` gumbold
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=4288E71C.2060400@bonbon.net \
--to=gumbold@bonbon.net \
--cc=glynn@gclements.plus.com \
--cc=linux-c-programming@vger.kernel.org \
/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).