http://topic.youkuaiyun.com/u/20080106/19/6f6ce379-d536-4699-a475-6e834a24d74b.html
这里的例子打印出当前工作目录下所有的文件:
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
int main(void)
{
DIR* dp;
struct dirent* ep;
dp = opendir( "./ ");
if (dp != NULL)
{
while (ep = readdir(dp))
puts(ep-> d_name);
(void) closedir(dp);
}
else
puts( "Couldn 't open the directory. ");
return 0;
}