Zdravim , predstavme si ze mame nasledujuci enumeracny typ :
enum type {
hospital = 1,
facility = 3,
petrol = 5,
fastfood = 7
};
Nasledne mam funkciu , kde tento enumeracny typ figuruje v pozicii parametra , a to konkretne :
struct poi {
double latitude;
double longitude;
enum type type;
char* description;
};
struct entry{
struct poi poi;
struct entry* next;
}
struct entry* find_closest(struct entry* first,double longitude, double latitude, enum type type){
struct entry* temp = first;
struct poi* me = (struct poi*)calloc(1,sizeof(struct poi));
me->latitude = latitude;
me->longitude = longitude;
while(temp->next != NULL){
if(get_distance_between(me,temp->poi) < distance && temp->poi->type == type) distance = get_distance_between(me,temp->poi);
temp = temp->next;
}
while(first->next != NULL){
if(get_distance_between(me,first->poi) == distance){
struct entry* result = (struct entry*)calloc(1,sizeof(struct entry));
result->poi = first->poi;
result->next = NULL;
return result;
}
}
return NULL;
}
problem nastava tuto : temp->poi->type == type
a to za stavu , ze funkcia je volana nasledovne :
find_closest(first,20,20,hospital | fastfood);
kde tych enumeracnych typov je v parametri viac.
Funkcia mi totizto stale "spapa" iba jeden.
Pytam sa vas teda, ako ziskat z parametra vsetky zadane enumeracne typy ?
Stale mi to totizto berie len jeden...
PS : Neviem na 100% ci je to uplny a funkcny kod , pisal som ho len z pameti a bez kompilacie
Dakujem :)