#include <dirent.h>
#include <sys/stat.h>
#include <stdio.h>
int main()
{
DIR *dp;
struct dirent *dirp;
struct stat statbuf;
if((dp=opendir("./"))==NULL)
{
printf("目录名不正确/n");
return -1;
}
int num=0;
while((dirp=readdir(dp))!=NULL)
{
lstat(dirp->d_name,&statbuf);
if(S_ISDIR(statbuf.st_mode))
{
if(strcmp(dirp->d_name,".")==0 || strcmp(dirp->d_name,"..")==0)
continue;
printf("is dir:%s/n",dirp->d_name);
}
else
printf("%s/n",dirp->d_name);
num++;
}
return 0;
closedir(dp);
}