标签:root sed stdio.h while call fail null 操作 目录操作
#include <stdio.h>int main(void)
{
DIR dir = NULL;
struct dirent ptr = (struct dirent )calloc(1, sizeof(struct dirent));
struct dirent result = NULL;
dir = opendir("/root/tmp");
if (!dir) {
printf ("opendir failed\n");
return 1;
}
while ((readdir_r(dir, ptr, &result)==0) && (result != NULL)) {
printf ("name:%s\n", result->d_name);
}
closedir(dir);
return 0;
}
标签:root sed stdio.h while call fail null 操作 目录操作
原文地址:http://blog.51cto.com/13603157/2326577