readdir 函数通常用于读取目录中的文件和子目录。在C语言中,readdir 函数的原型如下:
readdir
#include <dirent.h> struct dirent *readdir(DIR *dirp);
readdir 函数的返回值是一个指向 struct dirent 结构体的指针。struct dirent 结构体包含了关于目录中条目的信息,例如文件名、inode号等。如果读取到目录末尾或者发生错误,readdir 函数将返回 NULL。
struct dirent
NULL