I'm new to C++. I was attempting to write a function for selection sort the following way.
void selection_sort(int* m[], int array_size) {
for (int i = 0; i < array_size; i++)
int min_ind = i;
for (int j = i+1; j < array_size; j++){
if (m[min_ind] > m[j]){
min_ind = j;
}
}
int temp = *m[i];
*m[i] = *m[min_ind];
*m[min_ind] = temp;
}
}
Within main, the array is defined as:
int *sel_nums = new int[n];
And I'm calling selection sort in main:
selection_sort( &sel_nums, x );
I keep getting an error that says:
Segmentation fault (core dumped)
Does anyone have any input on why this keeps happening?