summary refs log tree commit diff
path: root/manual/examples/dir.c
blob: 59ec62c84c328695778949c17c6aee6cf4bc29a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*@group*/
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
/*@end group*/

int
main (void)
{
  DIR *dp;
  struct dirent *ep;

  dp = opendir ("./");
  if (dp != NULL)
    {
      while (ep = readdir (dp))
	puts (ep->d_name);
      (void) closedir (dp);
    }
  else
    perror ("Couldn't open the directory");

  return 0;
}