Thread: Simple typedef question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Simple typedef question

    Hi,

    If i have the following:
    Code:
    struct stackNode {
       int data;
       struct stackNode *nextPtr;
    };
    
    typedef struct stackNode StackNode;
    typedef StackNode *StackNodePtr;
    I know the 2nd last line is just to save some work when declaring variables with the type struct stackNode. But what's the last line for? Why has it got the asterisk there? Why make it a pointer. Note that i'm now learning linked lists, stacks and quese at the moment. ALso, can i reduce the last two lines with this:
    Code:
    typedef struct stackNode *StackNodePtr;
    Is this the way to do it in one line what the 2 lines are doin?

    many thnx
    Last edited by Nutshell; 02-02-2002 at 06:20 PM.

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