I need to provide functionality in a program that needs to search through a linked list of dinners.
The problem is I need to be able to search for every single attribute. So for the code
Code:
Restaurante* encontrarRestauranteString (char* string){
No* auxiliar = cabeca;
No* anterior = NULL;
int encontrou = F;
for(; auxiliar != NULL && encontrou == F; auxiliar=auxiliar->proximo)
{
if(auxiliar->restaurante->localizacao.latitude == coord->latitude )
{
return auxiliar->restaurante;
}
else
anterior=auxiliar;
}
return NULL;
}
All I need to do is change the attribute of restaurante for every single attribute. Do I need to do this manually or can I somehow tell it in the incoming variables which thing I'm interested in so it would look something like
Code:
Restaurante* encontrarRestauranteString (?? attribute, char* value_of_attribute){
No* auxiliar = cabeca;
No* anterior = NULL;
int encontrou = F;
for(; auxiliar != NULL && encontrou == F; auxiliar=auxiliar->proximo)
{
if(auxiliar->restaurante->atribute == value_of_attribute)
{
return auxiliar->restaurante;
}
else
anterior=auxiliar;
}
return NULL;
}
Don't know if I was able to explain my question properly. Please tell me if I didn't.
Thanks in advance.