how can i use qsort to sort alphabetically strings of a 2d array which has strings for a example if i have an array of 4 rows and every row has a string of >=50 characters …how can i use the qsort function to sort string alphabetically ?
i used this
qsort(arr, i, 500*sizeof(arr[0]), compare);
for (j=0; j<i; j++) {
printf("%s\n",arr[j]);
}
and the comparator i used is
int compare (const void * a, const void * b ) {
return strcmp(a, b);
}
but it gives me segmentation fault error while trying to compile
This way it would work.