#include #include /* for qsort */ #include char *names[] = { /* An array of pointers to string literals */ "Mary", "Billy", "Zoe", "Peter", "Nigel", "Sandeep", "Alison" }; int textcmp(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } main() { int i; const int count = sizeof names / sizeof names[0]; /* no. of elements */ qsort(names, count, sizeof names[0], textcmp); for (i=0; i<7; i++) { printf("%s\n", names[i]); } return 0; }