0
我试图结构数组上使用qsort
,但我得到这个错误:之前预期主表达式“*”令牌与数组结构的qsort?
struct muchie {
int x,y,c;
} a[100];
int cmp(const void* p, const void* q)
{
muchie vp,vq;
vp=*(muchie* p);
vq=*(muchie* q);
return vp.c-vq.c;
}
// ....
qsort(a,m,sizeof(muchie),cmp);
提供正确的转换符:'(muchie *)' –
只要使用'的std :: sort',这就是它是。 –