Re: [OFF-TOPIC/C] Acessing members (-> and .)

From: d. hall (dhall@APK.NET)
Date: 11/24/97


+// thus on Sat, 22 Nov 1997 13:34:47 -0800, Daniel virtually wrote:

Daniel> 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.

Daniel> Okay, really quickly: there's two ways to access a member of a
Daniel> structure, with a '.' or with a '->'.  They do the same thing,
Daniel> except for different types of structures. The '.' notation is used
Daniel> for non-pointers, and the '->' used for pointers.  Example:

The "->" is a shorthand reference for the long hand version:

        (*node_pointer).element

It's more commonly used, kinda like the function pointer.  Hardly anyone
refers to the function points as...

        int get_size (int);
        int (*func) (int);

        func = get_size;

        (*func) (13);

They refer to it's shorthand:

        func (13);

d. "just think, when C9x comes out, it'll be even more confusing..."


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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