I need to create a funcion that receive a struct pointer and a void pointer, it return 1 if the element is on the struct.
typedef struct {
char *sx;
int val, code, qtty;
char abc [20];
} ST_DAT;
int compare (ST_DAT *, void *);
This is part of a program that compare nodes in a double linked list, but this funcion is used as:
int (*pfun)(ST_DAT *, void *));
The problem is that I don't know how to compare the void * to the other values until I find or not the value inside.
int compare (ST_DAT *stData, void *key)
{
if (key == (*stData).val || key == (*stData).code || key == (*stData).qtty || strcmp (key,(*stData).abc) || strcmp (key,(*stData).sx) )
{
return 1;
}else{
return 0;
}
}
Is this correct?
Aucun commentaire:
Enregistrer un commentaire