- 论坛徽章:
- 0
|
/*checkdir.c*/
#include <stdio.h>;
#include <stdlib.h>;
#include <sys/types.h>;
#include <sys/dir.h>;
#include <dirent.h>;
int checkdir();
int main()
{
printf("\nnormal...\n" ;
checkdir();
return(0);
}
int checkdir()
{
extern int scandir();
extern int alphasort();
int num_entries, i;
struct dirent **namelist, **list;
num_entries = scandir("/tmp", &namelist, NULL, NULL);
if ( num_entries < 0 )
{
fprintf(stderr, "Unexpected error\n" ;
exit(1);
}
printf("Number of entries is %d\n", num_entries);
if (num_entries)
{
printf("Entries are:" ;
for (i=0, list=namelist; i<num_entries; i++)
{
printf(" %s", (*list)->;d_name);
free(*list);
list++;
}
free(namelist);
printf("\n" ;
}
printf("\n" ;
return(0);
}
/*
int checkdir()
{
DIR *dirp;
struct dirent *direntp;
dirp = opendir("." ;
while ((direntp = readdir(dirp)) != NULL)
(void)printf("%s\n", direntp->;d_name);
closedir(dirp);
return (0);
}
*/
$ cc checkdir.c
Undefined first referenced
symbol in file
scandir checkdir.o
UX:ld: ERROR: Symbol referencing errors. No output written to a.out
$ CC checkdir.c
"checkdir.c", line 25: error: too many arguments in function call
num_entries = scandir("/tmp", &namelist, NULL, NULL);
^
$
但是在HP-UX上没问题,请大家帮忙解决一下,谢谢! |
|