It looks like you're going in the right direction. However, you do have a few problems. Your search function doesn't do what I think it's supposed to; you're never comparing the node data to the searchItem pointer, and you can't compare unequivalent types. The
node variable in that function isn't declared properly, either.
And by the way, I have no idea what the
*list pointer is for either. You technically don't need it.
To remove an item from a linked list, do the following:
1) Search through the list until you find the node
before the item you want.
2) Save the
next pointer of item you want to delete.
3) Set the
next pointer of the current node (the node that comes before the node to delete) to the
next pointer of the node to be deleted.
4) Delete the node.
Code:
void deleteNthNode(unsigned int n)
{
Node *curr = head;
for(unsigned int i = 0; i < n; ++i)
curr = curr->next;
//save pointer to node to be deleted
Node *temp = curr->next;
//break link by bypassing the node we want to delete
curr->next = temp->next;
//delete undesired node
delete temp;
}