iter is set to the head of the linked list, and if the linked list doesn't yet exist, you reply that the item is "not found\n""not found\n". I would change this to "Linked list is empty.\n""Linked list is empty.\n"
This doesn't seem to work in the sense that it does not actually delete the element. If you want this item deleted -- which I'm assuming you do, given the name of the function -- then you should add this line: head = head->next; (You'll need to pass the head parameter "by reference" to make sure that this change will propagate outside the code of the delete_item function. Normally, if the parameter being passed wasn't a pointer, this would be done by passing the pointer. head head is a node*node*, however, and I have forgotten how to pass a pointer by reference... I think it would either be node*& head or node** head ... sorry, but you'll have to figure that one out! :) ) Alternatively, you could have delete_item return a node *, and at the end of the function, you could return the first non-matching entry, and this would be called by head=delete_item(head, x)head=delete_item(head, x). It's probably slightly frowned upon to do it that way, but it would be an easy way out.
At any rate, once you get that accomplished, it will delete the current head, and the new head will be the second element, if one exists... else it will be set to NULLNULL.
One problem I see is that you have to decide if you want to delete duplicate entries. For example, if 77 appears twice in the linked list, do you want to delete both 7s7s, or just one? If you want to delete both, you need to traverse the entire linked list by removing the return statements in the whilewhile loop and the initial check of the head node. This will create a problem as the program proceeds on to the final, "not found" statement, but that can be solved with an ifif statement:
entryfoundentryfound would have to be declared to be 00, and set to 11 if a match was found in the whilewhile loop. Alternatively, you could do entryfound++entryfound++ in the event of a match and change this last line: