Re: gets() and "string" variable type

new topic     » goto parent     » topic index » view thread      » older message » newer message

Matt Lewis wrote:
> 
> Pete Lomax wrote:
> > 
> > PS [OT] Can someone explain
> > 	top = (object)*(top + ((s1_ptr)obj_ptr)->base);
> > 
> pointer arithmetic.  When you add 1 to a pointer, it points to the next
> place in memory, *after the current value*.  applies for structs, too, BTW.
Ah! I see, it is the definition of base as long* which does it.

> Another way to have written this would be:
> 
>    top = ((s1_ptr)obj_ptr)->base[top]
> 
> Which, to me, is usually clearer
> 
Yes, much clearer. It was the "top+" part which confused me, also not realising
that C compilers recognise pointer arithmetic like that, and therefore tweak the
meaning of the "top+" just parsed with "* sizeof".

Still no fan of C though smile

Regards,
Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu