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...