void deletenode (int date)
{
ifstream fin;
ofstream fout;
fin.open("book");
fout.open("new");
ListNode * temphead = head;
ListNode * previous = NULL;
ListNode * tempnext = NULL;
while (temphead->date != date && temphead != NULL)
{
previous = temphead;
temphead = temphead->next;
}
if (temphead == NULL)
{
cout<<"Sorry no data found!!!"<<endl;
}
else if (previous == NULL)
{
tempnext = temphead->next;
head = tempnext;
delete temphead;
}
else
{
tempnext = temphead->next;
previous->next = tempnext;
delete temphead;
}
}
This post has been edited by jimblumberg: 01 May 2013 - 08:42 AM
Reason for edit:: Added missing code tags. Please learn to use them properly.

New Topic/Question
Reply


MultiQuote




|