Segmentation fault during pthread_create()

92 views Asked by At

Okay so I'm trying to bubble sort two files in a separate threads(main thread and the secondary thread in which I created using pthread_create). My bubble sort works perfectly, I tested it several times so I didn't included here, my problem it is giving me segmentation fault during the line pthread_create.

I have a bubble sort functions which reads the file and sorts it. Works perfect. void *bubblesortCars(char *filename)

THE PROBLEM THIS IS GIVING ME SEGMENTATION FAULT

pthread_create(&one, NULL, (void*)&bubblesortCars, (char *)&("FirstHalf.txt"));
bubblesortCars("SecondHalf.txt");
pthread_join(one, NULL); 

HOWEVER, if I put it this way it will work perfectly, but I do not want to do it this way, because I want both threads to bubble sort simultaneously:

bubblesortCars("SecondHalf.txt");
pthread_create(&one, NULL, (void*)&bubblesortCars, (char *)&("FirstHalf.txt"));
pthread_join(one, NULL); 
0

There are 0 answers