Thread: link list

  1. #1
    Unregistered
    Guest

    Lightbulb link list

    I need my program to use a linked list but have the options to
    1) add record
    2)delete record
    3)display all records
    4)save and exit the program
    the linked list needs to be sorted.

    What i have so far:

    node* Insert(node*pList)
    {
    node*pNew;
    node* pCur;
    node* pPre;
    pNew=(struct node*)malloc(size of(struct node));
    printf(Enter in new node");
    fflush(stdin);
    fgets(pNew>name,50,stdin);
    printf(Please enter in name");
    scanf("&ld", &new>Marks);
    pNew>linkptr=Null
    if(pList= = Null)
    {
    pList=pNew;
    }else
    {
    search(pList,&pPre, &pCur, p'new>marks);
    if(pPre==Null&&pCurr==pList)
    {
    pNew>link=Plist;
    pList=pNew;}
    else{
    pNew>linkptr=pCur;
    pPre>linkptr=pNew;
    }
    }
    return pList;
    }
    I am not sure this is right. I am a beginner and still working on this.
    If anyone can help or give advice please do so. Thanks

  2. #2
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    This is wrong "pNew>link ..." and should be pNew->link ...
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> 4)save and exit the program <<
    Well, with this you are going to have to do some simple file manipulation. How beginner are you?
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. Link List Insert prob
    By Bebs in forum C Programming
    Replies: 8
    Last Post: 12-03-2008, 10:28 PM
  3. reading data from a file - link list
    By peter_hii in forum C++ Programming
    Replies: 7
    Last Post: 10-25-2006, 09:11 AM
  4. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM