Code:
int compA(const void* item1, const void* item2) {
const Emp* emp1 = (const Emp*) item1;
const Emp* emp2 = (const Emp*) item2;
unsigned char buff1[BuffSize + 1];
unsigned char buff2[BuffSize + 1];
strcpy(buff1, emp1->lname);
strcat(buff1, emp1->fname);
strcpy(buff2, emp2->lname);
strcat(buff2, emp2->fname);
return strcmp(buff1, buff2);
}
and
Code:
int compB(const void* item1, const void* item2) {
const Emp** emp1 = (const Emp**) item1;
const Emp** emp2 = (const Emp**) item2;
unsigned char buff1[BuffSize + 1];
unsigned char buff2[BuffSize + 1];
strcpy(buff1, (*emp1)->lname);
strcat(buff1, (*emp1)->fname);
strcpy(buff2, (*emp2)->lname);
strcat(buff2, (*emp2)->fname);
return strcmp(buff1, buff2);
}
Or
Code:
void dump_emps1(Emp a[ ], unsigned n) {
102 int i;
char buffer[BuffSize + 1];
for (i = 0; i < n; i++) {
to_string(&a[i], buffer);
printf("%s\n", buffer);
}
}
and
Code:
void dump_emps2(Emp* a[ ], unsigned n) {
int i;
char buffer[BuffSize + 1];
for (i = 0; i < n; i++) {
to_string(a[i], buffer);
printf("%s\n", buffer);
}
}