Re: [CODE] [NEWBIE(I think)]

From: Baktor Silvanti (baktor@BEDFORD.NET)
Date: 11/22/97

Chuck Reed wrote:
> I have seen a lot of new stuff in C, but one thing is just really escaping
> me.  I cannot seem to figure out all the *->ch or *->* or whatever.  What in
> gods name does this "->" mean?  I have looked in my on-line C tutorials and
> I can't seem to find it.

I don't like flames, but your asking for the "Get a C book" routine.
"->" is a structure pointer operator.  Most people do have some trouble
understanding these as they deal with pointers...another fun subject.
The basic definition of these are:

structure pointer operator's-- stores or recalls data in a member of a
structure POINTED to by a pointer.

this means:

say we have a structure:

struct funky {
  char name[100];
  int age;
  int StinkyFingerIndicator;


struct funky *cd;  //This makes a pointer to a funky structure.

then somewhere else in code:

j = cd->age;     //This says, dereference (figure out) where cd points
                   to, then find the age member...J will equal whatever
                   is in the age member section.

I hope i done this all right, I'm sure i prolly messed something up and
will look stupid, but hey, that's the basics.  You might say, why not
just make cd a normal structure instead of a pointer.  The reason is
this, speed mostly.  Say you have a sorting function(qsort comes to
mind).  If you pass it an actual structure, it will be much slower than
if you would pass it a pointer (which is much smaller) to the same
function.  This also enables you to quickly sort data WITHOUT actually
moving the data from wherever it just sort pointers.

Well, I suggest if i didn't help much(and even if i did) to find an
advanced C book and read very carefully on pointers, "." and "->" as the
mud is full of them and you never really touch the power of C unless you
fully understand these concepts.

Baktor Silvanti

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

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