Licson Lee says to YSITD
template<T> void sort(T* x, int (*compare)(&T a, &T b)) { ... } int* test = malloc(sizeof(int) * 100); sort(test, compare);