Warning when using qsort in C

Posted by controlfreak123 on Stack Overflow See other posts from Stack Overflow or by controlfreak123
Published on 2010-04-01T15:49:36Z Indexed on 2010/04/01 15:53 UTC
Read the original article Hit count: 396

Filed under:
|

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;
}

and i have my declaration

int cmp (const int * value1,const int * value2);

and I'm calling qsort in my program like so

qsort(currentCases,round,sizeof(int),cmp);

when i compile it I get the following warning

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 *)’

The program works just fine so my only concern is why it doesn't like the way im using that?

© Stack Overflow or respective owner

Related posts about c

    Related posts about qsort