//DISPLAY 13.7 Function to Locate a Node in a Linked List //Function Declaration struct Node { int data; Node *link; }; typedef Node* NodePtr; NodePtr search(NodePtr head, int target); //Precondition: The pointer head points to the head of //a linked list. The pointer variable in the last node //is NULL. If the list is empty, then head is NULL. //Returns a pointer that points to the first node that //contains the target. If no node contains the target, //the function returns NULL. //Function Definition //Uses cstddef: NodePtr search(NodePtr head, int target) { NodePtr here = head; if (here == NULL) { return NULL; } else { while (here->data != target && here->link != NULL) here = here->link; if (here->data == target) return here; else return NULL; } }