#include #include #include #include int comp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); } int main(void) { DIR *dir; struct dirent *dp; dir = opendir("/bin"); char list[1024][64]; int cnt = 0; for (dp = readdir(dir); dp != NULL; dp = readdir(dir)) { char *t = dp -> d_name; if (t[0] != '.') strcpy(list[cnt++], t); } closedir(dir); qsort(list, cnt, sizeof(char) * 64, comp); int i; for (i = 0; i < cnt; i++) printf("%s\n", list[i]); return 0; }