Re: [C in General] pointers

From: Mark A. Heilpern (heilpern@MINDSPRING.COM)
Date: 07/17/98

At 10:31 AM 7/17/98 -0700, you wrote:
>However, now we see stuff like:
>trig_data **trg_index;
>struct trig_data **trig_index;
>In any case, it seems to be a pointer to a pointer.  I'm still pretty
>newbie to pointers and the like, but I was hoping to finish obuild OLC for
>triggers.  Any ideas?

A structure in memory occupies some amount of space [sizeof(struct blah)],
contains your info, and specific structure elements are usually accessed as
varname.element   (but there are other ways).

A pointer to a structure contains (generally) 4 bytes, or however large is
needed to
store an address on your memory model. (4 byte addressing is good for 32Gig of
address space.) This pointer (address) is intended to be the address in
memory for
where your structure is. sizeof(struct blah *) is probably 4 unless you are
on some
arcane system. Specific structure elements are accessed generally as
however, to correlate this to the previous paragraph, I should point out
that this notation
is really intended to make things easy. A (perhaps?) more correct syntax to
access an
element of a structure pointer would be (*pointer).element (but, of course,
this generates
ugly code).

This is just the tip of the pointer iceburg (no pun intended)... you'll be
using them without
understanding them for quite some time because there are so many nuances of
under C.

Exercise to the reader: figure out function pointers, as used in
command_interpreter(). No
response is necessary :)

>BTW, the CircleMUD site hasn't got but one thing uploaded to the
>"contrib/code" dir in the past month.  First person to upload gets a cookie!

You can't upload there, you can only upload into incoming, and someone
has to move the file over.

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST