Main.POSIXDirectoryTypes


Types available in dirent.h to manage directory entries:

Header required:

#include <dirent.h>


type: DIR

A type representing a directory stream.


structure: dirent

A type representing a directory entry. Shall have the following members:

  • ino_t d_ino - file serial number.
  • char d_name[] - name of entry.

From the spec: The name of an array of char of an unspecified size should not be used as an lvalue. Use of:

  • sizeof(d_name)

is incorrect; use:

  • strlen(d_name)

...instead. The array of char d_name is not a fixed size. Implementations may need to declare struct dirent with an array size for d_name of 1, but the actual number of characters provided matches (or only slightly exceeds) the length of the filename.


See also