#include <sys/types.h> #include <dirent.h> DIR *opendir(const char *name);
#include <dirent.h> #include <sys/types.h> #include <stdio.h> #include <string.h> int main() { struct dirent *item; DIR *dp; dp = opendir("/"); if (dp != NULL) { for(;;) { item = readdir(dp); if (item == NULL) break; printf("DIR : %s\n", item->d_name); } closedir(dp); } }
Copyrights © - Joinc, All Rights Reserved. Inherited From - Yundream Rebranded By - Joonphil
사용법
설명
리턴값
에러
- EACCES
Permission 거부- EMFILE
프로세스에 의해서 너무 많은 파일이 열렸음- ENFILE
최근 시스템에 의해서 너무 많은 파일이 열렸음- ENOENT
name이 빈문자열 이거나 혹은 같은 이름의 디렉토리가 없음- ENOMEM
작업을 수행하기 위한 충분한 메모리가 없음- ENOTDIR
name이 디렉토리가 아님참고
예제코드
#include <dirent.h> #include <sys/types.h> #include <stdio.h> #include <string.h> int main() { struct dirent *item; DIR *dp; dp = opendir("/"); if (dp != NULL) { for(;;) { item = readdir(dp); if (item == NULL) break; printf("DIR : %s\n", item->d_name); } closedir(dp); } }Recent Posts
Archive Posts
Tags