How do I use the qsort() function? I have a string array of 5000 phone numbers and I know that there are 4 arguments, but I can't figure out how to enter the 3rd and 4th part of the function.
This is what I have.. and I get errors
string phone_num[5000];
qsort(phone_num, 5000, 0, ( sizeof(phone_num)/sizeof(phone_num[0])));
-> invalid conversion from `unsigned int' to `int (*)(const void*, const void*)'
-> initializing argument 4 of `void qsort(void*, size_t, size_t, int (*)(const void*, const void*))'
Look at the example; qsort (values, 6, sizeof(int), compare);
and your call qsort(phone_num, 5000, 0, ( sizeof(phone_num)/sizeof(phone_num[0])));
you have a zero for the size and the size where your compare function should be.
So it should be more like qsort(phone_num, 5000, ( sizeof(phone_num)/sizeof(phone_num[0])), compare);
EDIT
I think sizeof(string) makes more sense to me, but im hardly an expert.