I want to sort array by using" the quicksort algorithm"
so here is the code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

        void *triHoare      (void * arg);
        int  PivotSelection (int indexStart, int indexEnd);
	int  Split   (int tab[], int pivot, int indexStart, int indexEnd);
            int MAXTAB;

           struct  param                                 
             int indexStart;
             int indexEnd;
             int tab[100];
         int main(void)
            struct param arg;
            int i; pthread_t thred;
            int pere;
            arg.indexStart= 0;
            arg.indexEnd  = (MAXTAB-1);
            printf("Please input array size : ");
            printf("\n please input tab[%d] :",i);
            printf("Before sorting : ");                       
            for(i = 0; i < MAXTAB; i++) printf(" %d ",arg.tab[i]);// exit(0);
            if(pthread_create (&thred, NULL,*triHoare,&arg) ==0)
                    printf (" first thread created ");
                                 perror("Creation failure"); 

        int  PivotSelection ( int indexStart, int indexEnd)
        { return  (indexStart+indexEnd) /2;}

	void *triHoare (void * arg){  
	    struct param *p=(struct param*) arg;  
            struct param arg1,arg2;
            pthread_t id_thread;
            pthread_t ig_thread;
	    int pivot = PivotSelection (p->indexStart,p->indexEnd);             
	    int SplitIndex,th1,th2;
	    SplitIndex = Split(p->tab, pivot,p->indexStart,p->indexEnd); 

            arg1.indexStart = p->indexStart;
            arg1.indexEnd   = SplitIndex;
            arg1.tab[MAXTAB]= p->tab[MAXTAB];

            arg2.indexStart = SplitIndex+1;
            arg2.indexEnd   = p->indexEnd;
            arg2.tab[MAXTAB]= p->tab[MAXTAB];
	    if(p->indexEnd > p->indexStart)                                              

                    th1= pthread_create (&id_thread, NULL,*triHoare,&arg1);
                    if (th1 < 0) 
                                 perror(" creation threadG failure ");
                    th2= pthread_create (&ig_thread, NULL,*triHoare,&arg2);
		    if (th2 < 0) 
                                 perror("creation threadD failure");

                    if (pthread_join(id_thread, NULL))  

                    if (pthread_join(ig_thread, NULL))

                        printf("End first thread\n");  
                        return (EXIT_SUCCESS);


         int  Split   (int tab[], int pivot, int i, int j)
            int right,left;   
            int valeurPivot= tab[pivot];
            int x=0;
            left= i;
            right= j;

            while(left <  right)                                   

             while(( valeurPivot > tab[left])                  
	                && (left < j))                          

             while(( valeurPivot < tab[right])              
	                && ( right > i))                          
          if (left< right) {x= tab[left];tab[left]= tab[ right];tab[right]=x;}

         if (i==j) {printf("tab[%d]=%d \n",i,tab[i]);}
return ( right);}

after compiling the code ,i've got no error messages, I can just input the array elements , the array can't be sorted

If anyone can help that would be great, thank you

Where is the code breaking ?

Put some log statements to get a better idea of the behavior of your program

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.