void * bubbleSort(void * data){
int * str;
str = (int* ) data;
int temp = 0;
for ( int i = 0 ; i < len ; i++ ){
for (int j = i + 1; j < len ; j++ ){
if(str[i] > str[j]){
temp = str[i];
str[i] = str[j];
str[j] = temp;
}
}
}
}
int main(){
int *data= new int[1000000];
...
pthread_t thread[input];
for ( int i = 0 ; i < input ; i ++){
pthread_create(&thread[i],NULL,bubbleSort,arguments);
pthread_join(thread[i],NULL);
}
}
I have int *data[1000000] and I want to use pthread to pass parameter to bubble sort.
The above is the code I wrote, but it is no output
How to successfully work ?
int *data[10000];is creating 10000 pointers toint. You have to drop the*to get an array of 10000 integers:int data[10000];