my code of function is
bool search(node *head, int key)
{
node *temp = head;
while (temp != NULL)
{
if (head->data == key)
{
return true;
}
head = head->next;
}
return false;
}
and if condition in main function is
cin >> key;
if (search(head, key))
{
cout << “found”;
}
else
{
cout << “not found”;
}
i am getting segmentation fault when i give input as something which is not there in my linked list