hey guys. ive created this function that will delete the first element it finds in a linked list that has the value n in it. it works except when the number is the FIRST element in the list. it wont delete it, it will replace it with a 0 when i try and print the list for some reason.
the linked list is set out like this.
struct node
{
int number;
node *next;
}
void deleteNumber(node *t, int n)
{
node *current;
node *previous;
previous = NULL;
for (current = t; current!=NULL; previous = current, current = current->next)
{
if (current->number == n)
{
if(previous == NULL)
{
t = current->next;
}
else
{
previous->next = current->next;
}
delete current;
return;
}
}
}