Hello, I've been doing a program for my dad, so it could help him work better. I've been trying to make a function that finds a string or words that the user inputs. Here is what I got:
vstore sturcture:
Code:
struct storage
{
char name[100];
char id[100];
char description[100];
}temp;
Code:
void inline Buscar()
{
int counter=0;
char string[100];
cout<<"Entre la palabre que desea encontrar: "<<endl;
cin.getline(string,100,'\n');
for(int x=0; x<vstore.size(); x++)
{
for(int index=0; index<strlen(string); index++)
{
if(toupper(vstore[x].name[index]) == toupper(string[index]) )
{
counter++;
}
if( counter == strlen(string) )
{
global = vstore[x];
cout<<"Name: "<<vstore[x].name;
cout<<"\nID: "<<vstore[x].id;
cout<<"\nDesc.:"<<vstore[x].description<<endl;
}
else
{
cout<<"Didn't Find a MATCH"<<endl;
}
}
}
system("PAUSE");
return;
}
How can you make a more efficient code? As so far this one works Please someone help...