qsort question

alright, so i have used qsort as it is explained on cplusplus.com and a couple other sites in order to sort a list of pixel values (int) and select the median value. [-http://www.cplusplus.com/reference/clib-…-qsort.html ]

i cant seem to get qsort to work, it continues to return me this error:

‘int (testApp::)()’ does not match ‘int(const void*, const void *)’

after talking to zach, i tried this code

  
  
  
int modArray[9] = {texPixels[_ne], texPixels[_n], texPixels[_nw], texPixels[_w], texPixels[_me], texPixels[_e], texPixels[_se], texPixels[_s], texPixels[_sw]};  
  
static int compare(const void * a,const void * b ) {  
int* arg1 = (int*) a;  
int* arg2 = (int*) b;  
if( *arg1 < *arg2 ) return -1;  
else if( *arg1 == *arg2 ) return 0;  
else return 1;  
}  
  
qsort(modArray, 9, sizeof(int), compare);  
  
  

which returns the same error.

any suggestions?

-a

hi andrew

the code that I sent works for me…

can I ask you to post a zip of your source code? and / or a screen shot of the error ?

perhaps it’s how you are writing it - the compare function has to be a static function (ie not a part of a class)…

thanks
zach

cool, that totally worked. i moved it out of the class declaration in the h file.

thanks for the help!

-a