c++ linked list class

Hi guys
i cant find a search functin for a linked list that searches a linked list for a name that the user puts in.
i tried google and many other site cant find a smiple code..
Thanks

You simply need to iterate through the list?
look bro thats my code
my problem in find
""compare serchedname with name ""


#include <iostream.h>
#include <string.h>
class list{
char name[20];
list *next;
public:
void add();
void print();
int find();

};
list *head=NULL;
void list::add()
{
list *node=new list;
cin >> node->name;
node->next=NULL;
if(head==NULL)
head=node;
else{
node->next=head;
head=node;
}


}

void list::print(){
list *c=head;
while(c!=NULL)
{
cout << c->name<<"\t";
c=c->next;

}}

int list::find(){
list *f=head;
char searchname[20];
cout << "enter c value : ";
cin >> searchname;

/* here is my problem */

}
void main(){
list l;
for(int i=0;i<2;i++)
l.add();
l.print();
cout <<endl << l.find();
}
Topic archived. No new replies allowed.