#include <sys/types.h> #include <dirent.h> struct dirent *readdir(DIR *dir);
readdir
returns information about the next directory entry from
an HFS directory opened by opendir
. The dir
function is the value
returned by opendir
when the directory was opened. readdir
uses a single area for return information for each directory. This means
that each call to readdir
overlays the return information from
the previous call for the same directory. Whether or not information is returned
for the "."
and ".."
directory entries is not defined by the POSIX.1
standard. Under OpenEdition, these entries are returned.
The dirent
structure contains the following:
char *d_name
readdir
returns the pointer to a dirent
structure that
describes the next directory entry. readdir
returns a NULL
pointer when it reaches the end of the stream. readdir
returns
a NULL pointer and sets errno
if it is not successful.
rewinddir
illustrates the use of the
readdir
function.
opendir