I want to check duplicate values in an array

前端 未结 4 1760
梦谈多话
梦谈多话 2021-01-29 09:18

Hi i\'m really glad to know this site to ask question. I have a problem that i made an array. And then i want to check matching values in the array. For example,



        
4条回答
  •  时光说笑
    2021-01-29 10:03

    How do you use the "qsort"?

    qsort(( void * )array, 5 , sizeof( data[0] ) , my_sort );
    

    my_sort is a function to create your own. For example,

    int my_sort( const void * a , const void * b ) {
        if( *( int * )a < *( int * )b ) {
            return -1;
        }
        else
        if( *( int * )a == *( int * )b ) {
            // You can check here.
    
            return 0;
        }
        return 1;
    }
    

提交回复
热议问题