Thread: Delete node in linked list..

  1. #1
    Registered User
    Join Date
    Mar 2011

    Delete node in linked list..

    guys, how do i delete a node in linked list based on the user input value?

    is mine correct?
    void deleteList(List *pList)
    	int numDelete;
    	ListNode *pPre;
    	ListNode *pCur;
    	printf("Enter integer to be deleted : ");
    	scanf("%d", &numDelete);
    		while (pCur!=NULL)
    			if (pCur->entry==numDelete)
    my header code is like follwing..
    typedef int ListEntry;
    typedef struct listnode {
    ListEntry entry;
    struct listnode *nextnode;
    } ListNode;
    typedef int Position;
    typedef struct list {
    int count;
    ListNode *head;
    } List;
    please help me anyone? i really need to solve this assignment of mine in hurry.. thanks..

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    Have you tried it? What happens if numDelete is at the head of the list?
    If you understand what you're doing, you're not learning anything.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    New Zealand
    I remember already commenting on the problems with the above code, in another thread, and you haven't learnt anything from it yet. I'm not going to repeat what I've already said.

    Starting extra threads for no good reason will just get others fed up with you. You wont get more help than if you had one thread, you'll get less. Good luck with that.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Mar 2011
    I'm so sorry. Is there a way to close this thread?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2008, 07:54 PM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  4. Help here with qsort!
    By xxxrugby in forum C Programming
    Replies: 11
    Last Post: 02-09-2005, 08:52 AM
  5. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM