디렉토리에 txt파일 갯수 읽어오는건데요


참고로 디렉토리에 test.txt sample.txt data.txt 이렇게 총 3개가 있어요


위에껀 윈도우 제공 함수구요

아래껀 c 런타임 함수 이용하는건데


위에껀 파일 3개 있다고 정확히 나오는데

아래껀 1개밖에 안나오네요.. ㅜㅜ


void find_dir2(const char *path)

{

WIN32_FIND_DATA wfd;

HANDLE handle;

BOOL bResult = TRUE;


handle = FindFirstFile(path, &wfd);

if (handle == INVALID_HANDLE_VALUE) return;


int i = 0;

while (bResult) {

i++;

printf("%s ", wfd.cFileName);


bResult = FindNextFile(handle, &wfd);

}

FindClose(handle);


printf("총 파일 갯수 : %d", i);

}


void find_dir(const char *dir)

{

_finddata_t fd;

long handle;

bool result = true;


handle = _findfirst(dir, &fd);

if (handle == -1) return;


int i = 0;

while (result) {

i++;

printf("파일명 : %s 크기: %d ", fd.name, fd.size);


result = _findnext(handle, &fd);

}

_findclose(handle);


printf("총 파일 갯수 : %d", i);

}