@node readdir, file system @subheading Syntax @example #include struct dirent *readdir(DIR *dir); @end example @subheading Description This function reads entries from a directory opened by @code{opendir} (@pxref{opendir}). It returns the information in a static buffer with this format: @example struct dirent @{ unsigned short d_namlen; /* The length of the name (like strlen) */ char d_name[MAXNAMLEN+1]; /* The name */ @}; @end example Note that some directory entries might be skipped by @code{readdir}, depending on the bits set in the global variable @code{__opendir_flags}. @xref{opendir, __opendir_flags, opendir}. @subheading Return Value A pointer to a static buffer that is overwritten with each call. @subheading Portability @port-note posix The @code{__opendir_flags} variable is DJGPP-specific. @portability !ansi, posix @subheading Example @example DIR *d = opendir("."); struct dirent *de; while (de = readdir(d)) puts(de->d_name); closedir(d); @end example