Results 1 to 2 of 2

Thread: What does this sign do?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2001
    Posts
    40

    What does this sign do?

    I've looked in some gamecode and I don't understand what this sign does: test->test2. What does the '->' sign do exactly?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's the indirect-access operator. For example:
    Code:
    struct mystruct {
        int y;
        int x;
    };
    
    mystruct str;
    mystruct *ptr = &str; // Get pointer to str
    
    int num = ptr->y;
    int snd = str.x;
    So, it's basically: pointer->member, and is equivalent to (*ptr).member. It's to make it more readable, because rather than:
    (*((*ptr).ptrmember)).member you can use ptr->ptrmember->member.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width