glibc/manual/examples/dir2.c
Roland McGrath dacb975a0d 2003-11-09 Roland McGrath <roland@redhat.com>
* manual/examples/dir2.c (one): Add const to argument type.
	Reported by J de Haan <j.de.haan@home.nl>.
2003-11-10 01:18:43 +00:00

30 lines
392 B
C

/*@group*/
#include <stdio.h>
#include <dirent.h>
/*@end group*/
static int
one (const 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;
}