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
", o->d_name, o->d_type, o->d_ino);
        }

        (void) closedir (dir);
    }
    else
    {
        perror ("Couldn't open the directory");
    }

    return 0;
}
原文地址:https://www.cnblogs.com/afxcn/p/3999075.html