- 论坛徽章:
- 0
|
我在调用readdir读取当前目录下的目录项时,发生Illegal seek错误。
我在网上找了老半天没找到原因。
大家帮我看看啥原因。
谢谢!
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <strings.h>
#include <string.h>
#include <time.h>
int
main(int argc, char *argv[])
{
DIR *dir;
struct dirent *dirbuf;
if((dir = opendir("./")) == NULL)
return 1;
while((dirbuf = readdir(dir)) != NULL ) {
perror("test");
if(strcmp(dirbuf->d_name, ".") == 0 || strcmp(dirbuf->d_name, "..")== 0)
continue;
}
closedir(dir);
return 0;
}
[ 本帖最后由 LF_532 于 2007-7-9 11:07 编辑 ] |
|