- 论坛徽章:
- 0
|
《UNIX环境高级编程》第一个程序,"ourdhr.h"也已经有了,编译程序出错
[root@localhost 1]# cc myls.c
myls.c: In function `main':
myls.c:12: `NULL' undeclared (first use in this function)
myls.c:12: (Each undeclared identifier is reported only once
myls.c:12: for each function it appears in.)
请帮忙解答一下,谢谢了
#include <sys/types.h>;
#include <dirent.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);
} |
|