Hello guys,
I'm making a C++ project on periodic table.In that,i want to search for elements on the basis of their names in such a way that if i give an alphabet or more than 1 alphabets as the search value then all the elements starting from that letter should be displayed.
Suppose the search value is Lit,
then Lithium should be displayed.
Or if i give C as the search value then all the elements starting from C should be displayed..
Carbon
Calcium
Cerium
etc..
I've been able to develop the following function for this but it finds the element if the search value exactly matches the element name.
//The function starts here
void search()
{
ifstream o1;
o1.open("file"ios::binary);
int flag=0;
char name[10];//SEARCH VALUE
cout<<"Enter the element's name to be searched...";
cin>>name;
while(o1.read((char*)&object,sizeof(object)))
{
if(strcmpi(name,object.retname())==0)
//object.retname() is a function defined in class to return element's name
{
flag=1;
cout<<"\nElement found..."<<object.retname();
break;
}
}
if(flag==0)
cout<<"\nElement not found...";
o1.close();
}
Could anyone write the function for me to solve my problem......
PLEASE....
I NEED URGENT HELP//////