StudyingUnixInterface/4/fileDirectory/dirent.c
2020-12-07 12:17:01 +08:00

24 lines
375 B
C

#include <dirent.h>
#include <stdio.h>
int main(void) {
DIR *pdir = opendir(".");
if(pdir == NULL) {
printf("opendir error\n");
return -1;
}
struct dirent *pdirent = NULL;
while((pdirent = readdir(pdir)) != NULL){
long index = telldir(pdir);
printf("%15s %18ld %lu\n", pdirent->d_name, index, pdirent->d_ino);
}
closedir(pdir);
return 0;
}