Hi,
I wanted to search an element (char) in the list S, but everytime it said that 02x is not in S
How to declare char target in a manner way? i think its my mistake for this code.
Thanks.
Code:
struct Node;typedef Node* NodePtr;
typedef void* VoidPtr;
typedef char* Ptr;
typedef int* Pi;
struct Node
{
VoidPtr data;
NodePtr next;
};
Code:
bool Search(NodePtr& head, VoidPtr& target)
{
bool found = false;
NodePtr here = head;
while (here != NULL && !found)
{
if (here->next ==target)
found =true;
else
here = here ->next;
return found;
}
}
void Search_Menu (NodePtr& head)
{
VoidPtr target;
cout <<setw(70)<<setfill('=')<<endl;
PrintList(head);
cout <<"\nWhich element?: ";
cin >>target;
if((Search(head, target)==true))
{
cout <<target<<" is in S ."<<endl;
}
else
{
cout <<target <<" is not in S."<<endl;
}
}