当我尝试使用qsort对结构数组进行排序时,我收到此错误:qsort无法从int转换为__compar_fn_t。
源代码是:
struct idpar_exchange
{
int idp;
long long int exchange_d;
};
int ptg_partitioning::compare_by_data(const void* a, const void* b)
{
struct idpar_exchange *ia= (struct idpar_exchange *)a;
struct idpar_exchange *ib= (struct idpar_exchange *)b;
return ia->exchange_d - ib->exchange_d;
}
struct idpar_exchange v[list_part.size()][list_part.size()];
qsort(v[i],(sizeof(v[i])/(sizeof(struct idpar_exchange))),sizeof(struct idpar_exchange),compare_by_data);