c代碼讀取目錄信息

  
  
  
  #include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
 
 
int main(void)
{
    DIR *dir;
    struct dirent *o;
    dir = opendir ("./");
 
 
    if (dir != NULL)
    {
        while ((o = readdir (dir)) != NULL)
        {
            printf("%s %d %llu\n", o->d_name, o->d_type, o->d_ino);
        }
 
 
        (void) closedir (dir);
    }
    else
    {
        perror ("Couldn't open the directory");
    }
 
 
    return 0;
}
相關文章
相關標籤/搜索