New example for scandir function.

This commit is contained in:
Ulrich Drepper 1997-03-17 03:55:21 +00:00
parent fb63ae13d0
commit 77055d99e4

29
manual/examples/dir2.c Normal file
View File

@ -0,0 +1,29 @@
/*@group*/
#include <stdio.h>
#include <dirent.h>
/*@end group*/
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 directory");
return 0;
}