Warning when using qsort in C

前端 未结 2 1650
无人共我
无人共我 2020-12-19 09:28

I wrote my comparison function

int cmp(const int * a,const int * b)
 {
   if (*a==*b)
   return 0;
else
  if (*a < *b)
    return -1;
else
    return 1;
}         


        
2条回答
  •  离开以前
    2020-12-19 10:00

    According to the man page, a __compar_fn_t is defined as: typedef int(*) __compar_fn_t (const void *, const void *)

    Your cmp specifies int* parameters. It doesn't like that, but is only listed as a warning.

提交回复
热议问题