C Programming/POSIX Reference/dirent.h

dirent.h is the header in the C POSIX library for the C programming language that contains constructs that facilitate directory traversing. The function is not part of the C standard, but is considered "pseudo-standard" and is usually portable between platforms.

Member constants
Constants defined in the  header include:

Member types
Data types defined in the  header include:
 * - A structure representing a directory stream. Its structure is not defined by POSIX, and is usually opaque to users.


 * - A structure with the following members:
 * - file serial number
 * - name of entry (will not exceed a size of NAME_MAX)


 * In addition,  may contain the following members, depending on the platform:
 * - file offset
 * - length of the dirent record
 * - length of name
 * - type of file

Standardization
dirent.h is included in most C/C++ libraries for the PC architecture.

dirent.h is known to be included in the following compilers:
 * Turbo C++ (DOS)
 * GCC (Cross-platform)
 * MinGW (a Microsoft Windows version of GCC)
 * Borland C++ Builder (Microsoft Windows)

Microsoft Visual C++ does not include dirent.h

Example
A short example of dirent.h usage is:

Put the source in a file (listdir.c) and compile ( in a Linux shell ) like this: gcc listdir.c -o listdir or like this: gcc listdir.c -o listdir.exe in a Windows/DOS environment.

Now, to run ( in a Linux shell ) type: ./listdir or type: listdir.exe in a Windows/DOS shell.