I have a question about the search function. A pointer is created in the main program Node *a = NULL; where the address of the next most recently created "trailer" is written. And when the add function finishes creating a chain, it will return a pointer to the last "trailer". And then the Find function is called. And how can it do a search if the address of the last element of the chain, but not the first one, was passed? Therefore, I do not understand why head = head->next; Don't stick everything in null. Where did I go in the wrong direction?
struct Node { int Data; Node* next; }; Node* add(Node *head, int Value) { Node *New = (Node*) malloc(sizeof(Node)); New->Data = Value; New->next = head; return New; } Node* Find(Node *head, int Value) { while (head) { if (head->Data == Value) return head; head = head->next; } return NULL; } int main() { Node *a = NULL; for (int i = 0; i < 5; i++) a = add(a, i); Node *del = Find(a, 2);