Thread: Your help would be greatly appreciated

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    4

    Question Your help would be greatly appreciated

    Based on the code and expressions below how far off am I on the correct answer? Thanks in advance for all your help!!!!
    code:
    __________________________________________________ __
    struct NodeType;
    typedef NodeType* NodePtr;

    struct NodeType
    {
    int number;
    char character;
    NodePtr link;
    };

    NodePtr currPtr = NULL;
    NodePtr firstPtr = NULL;
    NodePtr lastPtr = NULL;

    currPtr = new NodeType;
    currPtr -> number = 13;
    currPtr -> character = 'z';
    currPtr ->link = new NodeType;
    lastPtr = currPtr->link;
    lastPtr->number = 9;
    firstPtr = new NodeType;
    lastPtr ->link = firstPtr;
    fistPtr->number = 9;
    firstPtr->character = 'h';
    firstPtr->link = currPtr;

    __________________________________________________
    Expressions:

    a) firstPtr->link->number
    b) firstPtr->link->character
    c) firstPtr->link = = lastPtr
    d) currPtr->link->number
    e) currPtr->link = = *lastPtr
    f) firstPtr = = lastPtr->link
    g) firstPtr->number < firstPtr->link->number


    My thought:?????

    a. 9
    b. ‘h’
    c. invalid
    d. 13
    e. undefined
    f. invalid
    g. 9 – true

  2. #2
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    I could be worng but I think:

    a) 13
    b) z
    c) false
    d) 9
    e) false ( but true if the * wasn't there )
    f) true
    g) true

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    4

    Smile Thank you

    Thank you for your input!

  4. #4
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    currPtr->link == *lastPtr

    I'm not sure if this is a valid line. You try to compare a NodeType with a pointer. The compiler might give a warning/error on this one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Noobie question, all help greatly appreciated!
    By axehero in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2007, 09:47 PM
  2. Replies: 2
    Last Post: 05-10-2006, 10:43 PM
  3. Any assistance would be greatly appreciated
    By iiwhitexb0iii in forum C Programming
    Replies: 18
    Last Post: 02-26-2006, 12:06 PM
  4. Help Appreciated
    By cboard_member in forum C++ Programming
    Replies: 10
    Last Post: 08-02-2005, 06:31 AM
  5. Simple question. Help will be appreciated.
    By wickedclownz in forum C++ Programming
    Replies: 2
    Last Post: 06-19-2003, 02:18 AM