simplels.c
#include <stdio.h>
#include <dirent.h>
static int
one(struct dirent *unused)
{
return(1);
}
int
main(void)
{
struct dirent **eps;
int n;
n = scandir("./", &eps, one, alphasort);
if(n >= 0)
{
int cnt;
for(cnt = 0; cnt < n; cnt++)
puts(eps[cnt]->d_name);
}
else
perror("Couldn't open the diretory");
return(0);
}
From: http://www.delorie.com/gnu/docs/glibc/libc_276.html