Thread: help deciphering code

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    7

    help deciphering code

    hey guys confused about what some of this code does could you guys help put it in psuedo for me? (not all the code just some that i don't understand)

    (typedef struct)
    b_struct *bp
    int n = bp-> left + bp->right;
    a_struct *ap = &bp->a[i];
    ap->x[ap->idx] =n;


    i guess my question would be: what does "->" do?

  2. #2
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355

    Question

    Quote Originally Posted by tlovaj View Post
    i guess my question would be: what does "->" do?
    If you have a pointer to a structure, it is a way to access the members of the structure without having to dereference the pointer using the * dereference operator.
    Code:
    struct foo
    {
        int a;
        double b;
    };
    
    int main()
    {
        struct foo fooObject;
        struct foo *pointerToFooObject = &fooObject;
    
        /* Immediate access */
        fooObject.b = 7.56;
        /* Access with dereference. */
        (*pointerToFooObject).a = 5;
        /* The shorthand operator -> in action */
        pointerToFooObject->a = 12;  /* Now fooObject.a is 12 */
    
        return 0;
    }
    Last edited by xuftugulus; 03-10-2008 at 10:52 PM.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM