お返事お願いします。
void printdir(char *dir,int loop)
{ DIR *dp;
struct dirent *entry;
struct stat statbuf;
int num2=0;
int count=0;
char *dir2;
dir2=dir;
//中略
if((dp=opendir(dir2))==(DIR*)NULL){
fprintf(stderr,"bre cannot open directory:%s\n",dir2);
closedir(dp);
return;
}
while(num<loop&&(entry=readdir(dp))!=NULL){
printf("%p\t%s\t%p\n",dir2,dir2,dp);
stat(entry->d_name,&statbuf);
if(S_ISDIR(statbuf.st_mode)){
printf("!%p%10s\n", entry->d_name,entry->d_name);
//中略
printf("before%10s\\1 %p\\%5d\n",entry->d_name,entry,count);
printdir(entry->d_name,loop);
}else{
printf("%10s\\\\\n",entry->d_name);
}
printf("under%10s%5d%5d\n",entry->d_name,num,loop);
}
fprintf(stderr,"cannot open directory:%p%10s%4d%4dNULL:%10s\n",dp,entry- >d_name,num,loop,dir2);
chdir("..");
closedir(dp);
return;
//中略
}
opendirの判定をフォルダとファイルを区別したいです。
Windows XP
Borland C++
二年間1ヶ月C言語を使いました。
#include<stdio.h>
#include<dirent.h>
#include<string.h>
#include<sys/stat.h>
#include<stdlib.h>
#include<time.h>
を使っています。
お返事お願いします。