qsort(words, size1, size2, compareWords);
inside compare words:
int compareWords(const void *ac, const void *bc)
this works:
char const *a = *(const char **)ac;
these don't (a gets some garbage values):
char const *a = ac;
char const *a = (const char *) ac;
what is the rationale?
Also, in some examples I see size2 to be sizeof(char *). Shouldn't this be sizeof(*words)?
words is declared as:
char *words[] = {"abc", "pqr", "abcd", "pqsl"};
words, since you're asking questions about how to access it.size2is the size of one element. So,size2 = sizeof(*words)or bettersize2 = sizeof(char).*wordsis achar*so yeahsizeof(char*)is the same assizeof(*words)