#include #include #include #include #define NUMMAX 1000 #define LENMAX 50 char filename[NUMMAX][LENMAX+1]={{0}}; int qsort_strcmp(const void *a, const void *b){ return strcmp((char*)a, (char*)b); } int main(){ struct dirent *de; int i,j; DIR *dir; i=0; dir=opendir("/bin"); for(de=readdir(dir);de;de=readdir(dir)){ if(strcmp(de->d_name,".")&&strcmp(de->d_name,"..")){ strncpy(filename[i++],de->d_name,LENMAX); } } closedir(dir); qsort(filename,i,LENMAX+1,qsort_strcmp); for(j=0;j