#include<sys/types.h> #include <stdlib.h> #include <stdio.h> #include <dirent.h> #include <unistd.h> DIR * dir; struct dirent * ptr; dir=opendir(dir_path.c_str()); int i=0; while((ptr=readdir(dir))!=NULL) { if ( ".." == string(ptr->d_name) || "." == string(ptr->d_name) ) continue; printf("d_name: %s/n",ptr->d_name); } closedir(dir);