关于APUE第一个程序编译出错问题,在线等~
从APUE的书上抄了第一个程序1-1,ourhdr.h 我是从课本后面的附录上面打上的,然后放在了/usr/include/中,程序存储为ls.c,程序如下:
#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 argument (the directory name)is required");
if((dp=opendir(argv[1]))==NULL)
err_sys("can't open %s",argv[1]);
while((dirp=readdir(dp))!=NULL)
printf("%s\n",dirp->d_name);
closedir(dp);
exit(0);
}
编译:gcc ls.c ,出错问题如下:
[root@localhost ~]# gcc ls.c
ls.c: 在函数 ‘pr_mask’ 中:
ls.c:7: 错误:expected ‘;’, ‘,’ or ‘)’ before ‘{’ token
ls.c:21: 错误:原型函数定义中使用了旧式参数声明
ourhdr.h:35: 错误:省略了形参的名字
[root@localhost ~]#
大家帮忙看看是什么问题?谢~~