Delete node!!!!!

This is a discussion on Delete node!!!!! within the C Programming forums, part of the General Programming Boards category; Hello again guys. I created a employees data record previously using arrays. This time I'm suppossed to do the same ...

  1. #1
    Registered User khpuce's Avatar
    Join Date
    May 2003
    Posts
    165

    Delete node!!!!!

    Hello again guys. I created a employees data record previously using arrays. This time I'm suppossed to do the same thing using linked-lists!!! My program is working almost perfect (add,edit,display etc.) but I am completely stuck in deleting a record (node). I am using single link lists. I have very little idea about implementing linked-lists. Can anyone please help me on this? I want to keep (please don't ask why!!!) my function declaration as it is [ i.e. void Delete_Record(void) ]. Below is my code :

    Code:
    
    void Delete_Record(void)
    {
      struct record *current,*temp2;
      char id[3];
      int c;
      clrscr();
      textcolor(YELLOW);
      gotoxy (20,2);
      cprintf ("Wages/Tax/Insurance Employees Records Calculator ");
      gotoxy(5,5);
      textcolor(WHITE);
      cprintf("Delete a record :");
      gotoxy(5,6);
      cprintf("_________________");
      textcolor(WHITE);
      gotoxy( 8,13);
      current=head;
      cprintf("Enter Employee ID to delete [0-99] : ");
      gets(id);
      while (current!=NULL)
      {
        c=(strcmp(id,current->id));
        if (c==0)
        {
    
          prev->next=current->next;
          temp2=current;  
          free(temp2);
           break;
        } // end if
        if (current==NULL)
        {
          gotoxy(20,18);
          textcolor(LIGHTRED);
          cprintf("No such record ! Press any key to continue...");
          getche();
        } // end if
        current=current->next;
      } // end while
    
      } // end Delete_Record();
    Thanks...

  2. #2
    Registered User khpuce's Avatar
    Join Date
    May 2003
    Posts
    165
    Hell...o...o..Someone...Anyone...Please

  3. #3
    Registered User khpuce's Avatar
    Join Date
    May 2003
    Posts
    165
    I know its a common question. But I couldn't find the answer I am looking for. One thing about this one is I am not passing any parametres to the delete function. And since I am not good with linked lists, I am not sure how to use different other solutions already posted. So.....

  4. #4
    Registered User khpuce's Avatar
    Join Date
    May 2003
    Posts
    165
    Thank you very much...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Debugging my AVL tree program.
    By Nextstopearth in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 02:48 AM
  2. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21