LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 135|回复: 1

有关打开目录函数的问题,大家帮我看看源程序.

[复制链接]
发表于 2005-9-26 10:43:34 | 显示全部楼层 |阅读模式
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <string.h>
                                                                                                                                               
int main(int argc,char **argv)
{
  char path[10];
  DIR *dirp;
  memset(path,0,10);
  strcpy(path,"/home");
  if((dirp=opendir(path))==NULL);
  {
    printf("3456");
    perror("opendir");
    exit(1);
  }
                                                                                                                                               
printf("1234");
closedir(dirp);
                                                                                                                                               
return 0;
                                                                                                                                              }

结果是
opendir: Success
3456

为什么opendir执行不成功呢?我怎样才能让他正常打开这个目录?
麻烦大家帮帮我,谢谢!
发表于 2005-9-26 11:49:10 | 显示全部楼层
Post by zdh

  if((dirp=opendir(path))==NULL);
  


opendir是正确的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表