CS/CE 218 Lecture -*- Outline -*- * generic pointers (type void*) (page 120) For defining general containers, procedures that can act on arguments of different types, a type that can be "anything" is needed But each basic type has a different size, so can't have a type any such that any x; x = 1; x = 3.14159; /* double */ makes sense But all pointers are the same size... so use a generic pointer type... pointers can be cast to void * and back without loss of information. -------------- void *generic[2]; int i = 27; double d = 3.14159; generic[0] = (void *) &i; generic[1] = (void *) &d; printf("%d %g\n", *((int *) generic[0]), *((double *) generic[1])); ------------- so can have non-homogeneous arrays, lists, etc. Q: Do you understand the qsort function on page 120?