Readdir
Readdir is a function from the POSIX C library used to read directory entries from a directory stream. It is declared in dirent.h and works in conjunction with opendir, which opens a directory and returns a DIR pointer that represents the directory stream.
The function prototype is struct dirent *readdir(DIR *dirp). On each successful call, readdir returns a pointer
The dirent structure provides information about each entry. The most commonly used field is d_name, the null-terminated
Usage typically follows a loop pattern: open the directory with opendir, repeatedly call readdir to obtain
Variants and portability notes: many systems offer readdir64 for large-file support, and some older code used