Project/Real_code/book/ch14/ch14-tsearch.c
int emp_name_id_compare(const void *e1p, const void *e2p)
{
	const struct employee *e1, *e2;
	int last, first;

	e1 = (const struct employee *) e1p;
	e2 = (const struct employee *) e2p;

	if ((last = strcmp(e1->lastname, e2->lastname)) != 0)
		return last;

	/* same last name, check first name */
	if ((first = strcmp(e1->firstname, e2->firstname)) != 0)
		return first;

	/* same first name, check ID numbers */
	if (e1->emp_id < e2->emp_id)
		return -1;
	else if (e1->emp_id == e2->emp_id)
		return 0;
	else
		return 1;
}
/* emp_name_id_compare --- compare by name, then by ID */
compare by name, then by ID
compare by name then by ID
int emp_name_id_compare(const void *e1p, const void *e2p)
{
	const struct employee *e1, *e2;
	int last, first;
	e1 = (const struct employee *) e1p;
	e2 = (const struct employee *) e2p;
	if ((last = strcmp(e1->lastname, e2->lastname)) != 0)
		return last;
	if ((first = strcmp(e1->firstname, e2->firstname)) != 0)
		return first;
	if (e1->emp_id < e2->emp_id)
		return -1;
	else if (e1->emp_id == e2->emp_id)
		return 0;
	else
		return 1;
}
int emp_name_id_compare ( const void * e1p , const void * e2p ) { const struct employee * e1 , * e2 ; int last , first ; e1 = ( const struct employee * ) e1p ; e2 = ( const struct employee * ) e2p ; if ( ( last = strcmp ( e1 -> lastname , e2 -> lastname ) ) != 0 ) return last ; if ( ( first = strcmp ( e1 -> firstname , e2 -> firstname ) ) != 0 ) return first ; if ( e1 -> emp_id < e2 -> emp_id ) return -1 ; else if ( e1 -> emp_id == e2 -> emp_id ) return 0 ; else return 1 ; }
emp_name_id_compare --- compare by name, then by ID
emp_name_id_compare --- compare by name then by ID
/* same last name, check first name */ /* same first name, check ID numbers */