LinuxSir.cn,穿越时空的Linuxsir!

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

没有ourhdr.h,看这个程序有问题吗?

[复制链接]
发表于 2003-11-18 16:07:01 | 显示全部楼层 |阅读模式
请大家运行一下,看对吗?怎么找到ourhdr.h:ask :ask
#include <sys/types.h>
#include <dirent.h>
#include "ourhdr.h"
int
main (int argc,char *argv{})
{
   DIR    *dp;
   struct dirent  *dirp
    if (argc != 2)
       err_quit("a single argment (the directory name)is required");
    if ((dp=opendir(argv[1])) == NULL )
       err_sys("cat't open %s",argv[1]);
   while ((dirp=readdir(dp)) != NULL)
      printf("%s\n",dirp ->d_name);
    close(dp);
    exit(0);
}
发表于 2003-11-18 17:11:09 | 显示全部楼层
char *argv{}  -->  char *argv[]

"err_quit" is a function writen by author himself.

you must write it by yourself,like this:
void err_quit(const char * s)
{
    fprintf(stderr,"%s\n",s);
    exit(1);
}
the same with "err_sys" (i think)

it use "exit",then you should "#inlude <stdlib.h>"
 楼主| 发表于 2003-11-18 17:50:04 | 显示全部楼层
谢谢,我找到那个头函数了。还要自己写:!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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