Go to the first, previous, next, last section, table of contents.


readdir

Syntax

#include <dirent.h>

struct dirent *readdir(DIR *dir);

Description

This function reads entries from a directory opened by opendir (see section opendir). It returns the information in a static buffer with this format:

struct dirent {
  unsigned short d_namlen;  /* The length of the name (like strlen) */
  char d_name[MAXNAMLEN+1]; /* The name */
};

Note that some directory entries might be skipped by readdir, depending on the bits set in the global variable __opendir_flags. See section opendir.

Return Value

A pointer to a static buffer that is overwritten with each call.

Portability

not ANSI, POSIX (see note 1)

Notes:

  1. The __opendir_flags variable is DJGPP-specific.

Example

DIR *d = opendir(".");
struct dirent *de;
while (de = readdir(d))
  puts(de->d_name);
closedir(d);


Go to the first, previous, next, last section, table of contents.