[[Programming]]
[[ここ:http://www.ncad.co.jp/~komata/c-frame.htm]]を参照
#include<stdio.h>
#include<dirent.h>
void main(argc,argv)
int argc;
char*argv[];
{
DIR *dir;
struct dirent *dp;
char path[512];
if(argc<=1){
strcpy(path,".");
}
else{
strcpy(path,argv[1]);
}
if((dir=opendir(path))==NULL){
perror("opendir");
exit(-1);
}
for(dp=readdir(dir);dp!=NULL;dp=readdir(dir)){
printf("%s\n",dp->d_name);
}
closedir(dir);
}