The sort routine mySort
is the issue. This compare function needs to be of type int (*)(const struct dirent **, const struct dirent **)
. For example:
int mySort(const struct dirent **e1, const struct dirent **e2) {
const char *a = (*e1)->d_name;
const char *b = (*e2)->d_name;
return strcmp(a, b);
}
Recommend changing to
int mySort(const struct dirent **e1, const struct dirent **e2);
int (*fnPtr)(const struct dirent **e1, const struct dirent **e2);