首先,明确一个类型DIR的含义: #include <dirent.h> DIR A type representing a directory stream. DIR是在目录项格式头文件dirent.h中定义的,它表示一个目录流类型. 一.opendir - open a directory SYNOPSIS #include <sys/types.h> #include <dirent.h> DIR *opendir(const char *name); DE…
readdir函数: struct dirent *readdir(DIR *dirp); The data returned by readdir() may be overwritten by subsequent calls to readdir() for the same directory stream. 成功时,readdir() 返回指向 dirent 结构的指针.(这个结构是静态分配的:不要试图去free(3) 它.)如果到达了上当结尾,NULL 被返回并保持ERRNO不变…
readdir, readdir_r - 读一个目录 readdir函数: struct dirent *readdir(DIR *dirp); The data returned by readdir() may be overwritten by subsequent calls to readdir() for the same directory stream. 成功时,readdir() 返回指向 dirent 结构的指针.(这个结构是静态分配的:不要试图去free(3) 它.)如…