Thread: Make node code - right?

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002

    Make node code - right?

    Node *MakeNode(StackE item)  
      Node *nptr;
      if( (nptr = malloc ( sizeof nptr) ) != NULL)     
            nptr = item;     
            return item;
                    return NULL;
    the structs for this are:
    typedef int StackE;
    typedef struct node{
    StackEntry entry;
    struct node *next;

    Returns: NULL if out of memory; otherwise a ptr to enough memory to hold a Node, with that node set to correct value(s), ready to be put on stack


  2. #2
    Registered User PutoAmo's Avatar
    Join Date
    Mar 2002
    typedef int StackE;
    Node *MakeNode (StackE item)
    Node *nptr = NULL;
    if (nptr = malloc (sizeof (Node)))
       nptr->entry = item;
    return nptr;
    Last edited by PutoAmo; 03-24-2002 at 02:34 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2008, 07:54 PM
  2. 8 Puzzle game solver with the Best-First algoritm
    By LordMX in forum C Programming
    Replies: 17
    Last Post: 08-11-2008, 10:00 AM
  3. urgent please please..
    By peter_hii in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2006, 06:35 AM
  4. Help here with qsort!
    By xxxrugby in forum C Programming
    Replies: 11
    Last Post: 02-09-2005, 08:52 AM
  5. I need help~~Hash~~THX!
    By freefallin in forum C Programming
    Replies: 5
    Last Post: 04-22-2004, 07:50 AM