rewinddir
相关函数opendir, closedir, readdir, telldir, seekdir
表头文件#include <dirent.h>
定义函数void rewinddir(DIR *dp);
函数说明rewinddir()用来设置参数dir目录流目前的读取位置为原来开头的读取位置,没有返回值。EBADF dir为无效的目录流
范例#include<sys/types.h>
#include<dirent.h>
#include<unistd.h>
main()
{
DIR * dir;
struct dirent *ptr;
dir = opendir(“/etc/rc.d”);
while((ptr = readdir(dir))!=NULL)
{
printf(“d_name :%s
”,ptr->d_name);
}
rewinddir(dir);
printf(“readdir again!
”);
while((ptr = readdir(dir))!=NULL)
{
printf(“d_name: %s
”,ptr->d_name);
}
closedir(dir);
}