Thread: the arrow thing.. ->

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    the arrow thing.. ->

    mm...what does the arrow thing do? lol i dont know what its called..therefore i have no clue what i'd search in google. i'm sure "the arrow thing" wouldn't come up with anything i'd be interested in.. example:
    Code:
    else if ( header->data != search_key ) {
        int dir = header->data < search_key;
         return find_subtree ( header->link[dir], search_key );
    }
    thats from the binary search tutorial and i dont know what its doing so its kind of hard to understand whats going on..



    also - how do you use the question mark? like i know its supposed to be a conditional, but what does it test?

    thanks
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    x->y means dereference x and refer to the field within the struct which x points to known as y, where x is a pointer to a struct, and y is a field within that struct.

    It is shorthand for (*(x)).y

    To attempt to clarify:
    Code:
    struct foo {
        int bar;
    };
    
    /* ... */
    
    struct foo baz;
    struct foo *p;
    
    p = &baz; /* now p points to baz */
    
    p->bar; /* this refers to baz.bar */
    a ? b : c means evaluate a, if a is true, evaluate b, if a is false, evaluate c.
    Last edited by cwr; 10-23-2005 at 10:29 PM. Reason: attempt at clarification

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So let's get this straight. You're going to code for food, but you don't know what the conditional operator or the arrow operator do? Good grief. Buy a book.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    thanks cwr.


    going to being your key words quzah ;]
    i dont like to buy books. they cost money and i dont read them. lol
    Registered Linux User #380033. Be counted: http://counter.li.org

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    i dont like to buy books. they cost money and i dont read them. lol
    Start.

  6. #6
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    i dont find they help me. i learn better from sample code and explanations of it.
    i took a c/c++ class at the college i go to and opened the book (b/c we had to in class) all of 5 times. i also tried reading it once or twice..didn't help.
    plus buying books is more expensive than reading online documentation. ..in a way..not if you substitute the cost of the internet for the cost of the books, but i<3myinternet lol
    Registered Linux User #380033. Be counted: http://counter.li.org

  7. #7
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by willc0de4food
    i dont find they help me. i learn better from sample code and explanations of it.
    Guess what programming books are generally full of? Hint: Sample code, and explanations of it.

  8. #8
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    i know. the book i had was called "C How to Program"
    Registered Linux User #380033. Be counted: http://counter.li.org

  9. #9
    Registered User
    Join Date
    Apr 2005
    Posts
    134

    Pointer trouble.

    sorry..

  10. #10
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >thats from the binary search tutorial and i dont know what its doing
    That's funny, most people ask "what's up with that dir thingy?". By the way, that tutorial is out of date. The current version can be found on my website, but be sure to save it if you want to complete it. I'm working on a complete rewrite that will improve the entire tutorials by leaps and bounds.

    >i dont like to buy books. they cost money and i dont read them.
    Think of books as an investment. I have several books that contain information that I have yet to see elsewhere, and they'll remain a valuable reference for as long as I continue programming. While you can learn to write good code just by looking at good code and talking to people, it's best to gather information from as many sources as possible.

    >i learn better from sample code and explanations of it.
    Don't we all? But at some point you'll find that you understand the syntax and semantics of the language, and just reading code and explanations of it won't give you enough insight into the logic behind the solution. When that happens, you'll be forced to drop more into theory to figure out what's going on, and the best way to do that is through books.
    My best code is written with the delete key.

  11. #11
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    Quote Originally Posted by nkhambal
    sorry..
    ???


    mm...prelude, what are some good books? right now i'm especially curious about binary searches / search trees / linked lists / hash tables. but also good books that are just juicy with good info :]
    and i like your website, it has good information.
    i'm using some of the info you have on random numbers and it works well thanks.
    Registered Linux User #380033. Be counted: http://counter.li.org

  12. #12
    Registered User
    Join Date
    Mar 2005
    Posts
    135

    ...

    Ah, nice site you got there Prelude. I Never knew you were a women. I always presume everyone on here, or in any other forum for that matter, that programmers are males. Which is true in most cases but this is a surprise. Anyway, I'm happy I stumbled upon your site because it has a lot of tutorials I've been wanting to indulge myself in. Thanks for the link.

    [p.s, You're a pretty women =P ]

  13. #13
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    And since nobody did it yet: the -> operator is called the "indirect member access" operator.
    Or something very similar.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #14
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    Quote Originally Posted by CornedBee
    And since nobody did it yet: the -> operator is called the "indirect member access" operator.
    Or something very similar.
    haha thanks.
    Registered Linux User #380033. Be counted: http://counter.li.org

  15. #15
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    Quote Originally Posted by Prelude
    >thats from the binary search tutorial and i dont know what its doing
    That's funny, most people ask "what's up with that dir thingy?". By the way, that tutorial is out of date. The current version can be found on my website, but be sure to save it if you want to complete it. I'm working on a complete rewrite that will improve the entire tutorials by leaps and bounds...
    mm..Prelude ? why would completing the tutorial now make sense if your going to update it and its going to be better? lol it seems to me that the better choice would be to wait until the update and THEN go through the tutorial...? lol idk, maybe its just me but..


    unless its going to be like, a month before the update. lol ?
    Registered Linux User #380033. Be counted: http://counter.li.org

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 01-03-2006, 03:02 AM
  2. Replies: 10
    Last Post: 12-03-2005, 10:53 PM
  3. dec -> bin -> hex in arrays
    By chris1985 in forum C Programming
    Replies: 2
    Last Post: 05-09-2005, 08:15 AM
  4. Ascii code for arrow keys
    By beginner in forum C Programming
    Replies: 1
    Last Post: 11-07-2002, 01:29 PM
  5. Using Arrow Keys in Windows
    By Xterria in forum Game Programming
    Replies: 4
    Last Post: 10-22-2001, 08:21 PM