/* 获取某个目录下的文件(夹)名 */
#include
#include
int main(void)
{
DIR *dptr;
struct dirent*fptr;
char dir_str[256];
printf("Please input the dir path:\n");
scanf("%s", dir_str);
dptr = opendir(dir_str);
if (dptr == NULL) {
printf("WRONG DIR PATH!\n");
return -1;
}
while (fptr = readdir(dptr)) {
printf("%s\n", fptr->d_name);
}
closedir(dir_str);
return 0;
}
阅读(1307) | 评论(0) | 转发(0) |