23,110
社区成员
发帖
与我相关
我的任务
分享
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <time.h>
int main(int argc, char **argv) {
DIR *dirp;
struct dirent *direntp;
int stats;
char buf[80];
if (argc != 2) {
printf("Usage:%s filename\n\a", argv[0]);
exit(1);
}
if ((dirp = opendir(argv[1])) == NULL) {
printf("Open Directory %s Error:%s\n",
argv[1], strerror(errno));
perror("Error num");
exit(1);
}
while ((direntp = readdir(dirp)) != NULL){
printf("%s/%s\n",argv[1],direntp->d_name);
}
exit(1);
}