我写了自己的比较函数。
我正在程序中使用如下方式调用qsort函数:
当我编译它时,会出现以下警告。
该程序运行良好,所以我唯一的担忧是为什么它不喜欢我使用的方式?
int cmp(const int * a,const int * b)
{
if (*a==*b)
return 0;
else
if (*a < *b)
return -1;
else
return 1;
}
我有我的声明
int cmp (const int * value1,const int * value2);
我正在程序中使用如下方式调用qsort函数:
qsort(currentCases,round,sizeof(int),cmp);
当我编译它时,会出现以下警告。
warning: passing argument 4 of ‘qsort’ from incompatible pointer type
/usr/include/stdlib.h:710: note: expected ‘__compar_fn_t’ but argument is of type ‘int
(*)(const int *, const int *)’
该程序运行良好,所以我唯一的担忧是为什么它不喜欢我使用的方式?