When you call qsort for integers, pass cmpint as the last argument. Now you are using cmpstr in both cases.