Nicle wrote:
>
>
> Ok!
> Maybe, I should write some pseudocode:
>
> void foo(Element_t *p){
> int_t array_len = 0;
>
> array_len = sizeof(p)/sizeof(Element_t);
> }
>
> 2009/4/10 Paul Herring <[email protected] 
> <mailto:pauljherring%40gmail.com>>
>
> >
> >
> > On Fri, Apr 10, 2009 at 4:06 AM, Nicle <[email protected] 
> <mailto:ynicle%40gmail.com><ynicle%40gmail.com>>
> > wrote:
> > > I pointed out the 32bits system that was just for "sizeof(p)", not for
> > > "sizeof(char)".
> >
> > You're missing my point. sizeof(char) is always redundant.
> >
> > > Under 32bits system, always "4", cause: 4/1=4.
> >
> > And anyway, where CHAR_BIT is 32, it's not inconceivable that your
> > code snippet would return 1, not 4.
> >
> > --
> > PJH
> >
> > http://shabbleland.myminicity.com <http://shabbleland.myminicity.com>
> > http://www.chavgangs.com/register.php?referer=9375 
> <http://www.chavgangs.com/register.php?referer=9375>
> >
> >
>
> [Non-text portions of this message have been removed]
>
> 
I'm not sure if you are just using that code to make a point, but that 
won't work. You are getting the size of the pointer (which is usually 4 
or 8 bytes), and dividing that by the size of the type. If you have an 
array of 20 integers, your "formula" would return 1 (on 32-bit processors).

Its simpler to just make an array wrapper (or use a linked list for c), 
so you can manage the size.

Reply via email to