Back to index

glibc  2.9
dir2.c
Go to the documentation of this file.
00001 /*@group*/
00002 #include <stdio.h>
00003 #include <dirent.h>
00004 /*@end group*/
00005 
00006 static int
00007 one (const struct dirent *unused)
00008 {
00009   return 1;
00010 }
00011 
00012 int
00013 main (void)
00014 {
00015   struct dirent **eps;
00016   int n;
00017 
00018   n = scandir ("./", &eps, one, alphasort);
00019   if (n >= 0)
00020     {
00021       int cnt;
00022       for (cnt = 0; cnt < n; ++cnt)
00023        puts (eps[cnt]->d_name);
00024     }
00025   else
00026     perror ("Couldn't open the directory");
00027 
00028   return 0;
00029 }