2.9
[glibc/nacl-glibc.git] / manual / examples / dir2.c
bloba75c8857427623fb9467e2053a847ad63fc3ed68
1 /*@group*/
2 #include <stdio.h>
3 #include <dirent.h>
4 /*@end group*/
6 static int
7 one (const struct dirent *unused)
9 return 1;
12 int
13 main (void)
15 struct dirent **eps;
16 int n;
18 n = scandir ("./", &eps, one, alphasort);
19 if (n >= 0)
21 int cnt;
22 for (cnt = 0; cnt < n; ++cnt)
23 puts (eps[cnt]->d_name);
25 else
26 perror ("Couldn't open the directory");
28 return 0;