This commit is contained in:
Peter Petrek 2021-10-14 23:59:06 +02:00
parent 3e76694b5e
commit dcad10bfb5

View File

@ -14,6 +14,7 @@ struct jedlo {
};
int compare(const void* p1,const void*p2);
int abeceda(const void* p1, const void* p2);
int main() {
@ -44,6 +45,7 @@ int main() {
}
counter2 = (counter2 / 2);
qsort(databaza, counter2,sizeof(struct jedlo),abeceda);
qsort(databaza, counter2,sizeof(struct jedlo),compare);
for(int z=0; z<counter2; z++){
@ -69,4 +71,12 @@ int compare(const void* p1,const void*p2){
order = 0;
}
return order;
}
int abeceda(const void* p1, const void* p2) {
struct jedlo* s1=(struct jedlo*)p1;
struct jedlo* s2=(struct jedlo*)p2;
int result = strcmp(s1->name, s2->name);
return result;
}