利用 _findfirst 與 _findnext 完成
程式圖片:
程式碼:
#include <stdio.h>
#include <string.h>
#include <io.h> //c_file
#include <direct.h>
#include <iostream>
using namespace std;
void main()
{
char sdir[256], filter[256], path[256];
struct _finddata_t c_file;
intptr_t hFile;
strcpy_s(sdir, "human");
strcpy_s(filter, "*.jpg");
_chdir(sdir);
hFile = _findfirst(filter, &c_file);
if (hFile != -1)
{
do {
sprintf_s(path, "%s\\%s", sdir, c_file.name);
cout << path<<endl;
} while (_findnext(hFile, &c_file) == 0);
}
system("pause");
}
沒有留言:
張貼留言