Thread: Simple typedef question

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This works too:

    #define NodePtr struct *Node

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

  2. #17
    Registered User
    Join Date
    Mar 2002
    Posts
    22

    Question Doubt!

    Nutshell wrote:

    typedef struct stackNode StackNode;
    typedef StackNode *StackNodePtr;
    ----------------------------------------------------

    First typedef: StackNode is synonymic to struct stackNode.

    Second typedef, it can be rewrited as "typedef struct stackNode *StackNodePtr", true or false?

    If this is true, then *StackNodePtr is synonymic to StackNode which is also struct stackNode. Then, how on earth a pointer can be a synonym to a structure?? I'm really confuse. Please help!

  3. #18
    Unregistered
    Guest
    Second typedef, it can be rewrited as "typedef struct stackNode *StackNodePtr", true or false?

    If this is true, then *StackNodePtr is synonymic to StackNode which is also struct stackNode. Then, how on earth a pointer can be a synonym to a structure?? I'm really confuse. Please help!

    *StackNodePtr is not synonymous to StackNode. "typedef struct stackNode *StackNodePtr" declares a POINTER to the stackNode struct. StackNode, on the other hand, is declared as a synonym for struct stackNode, but NOT a pointer to that struct. So that's the difference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Question!!
    By gameuser in forum C++ Programming
    Replies: 2
    Last Post: 06-06-2009, 05:42 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. typedef struct question
    By flevine100 in forum C Programming
    Replies: 1
    Last Post: 09-03-2002, 09:34 PM