Re: gets() and "string" variable type
- Posted by Pete Lomax <petelomax at ??ueyonder.co.uk> Sep 15, 2007
- 541 views
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 Regards, Pete