I want to get txt files from directory with using c++. I searched in google and found "dirent.h" but I can't using this library. It gives me a C1083 fault. Here is my codes.I'm already included fstream,dirent.h vs...
ifstream fin;
string dir, filepath;
int num;
DIR *dp;
struct dirent *dirp;
struct stat filestat;
cout << "dir to get files of: " << flush;
getline(cin, dir);  
dp = opendir(dir.c_str());
if (dp == NULL)
{
    cout << "Error(" << errno << ") opening " << dir << endl;
    return errno;
}
while ((dirp = readdir(dp)))
{
    filepath = dir + "/" + dirp->d_name;
    if (stat(filepath.c_str(), &filestat)) continue;
    if (S_ISDIR(filestat.st_mode))         continue;
    fin.open(filepath.c_str());
    if (fin >> num)
        cout << filepath << ": " << num << endl;
    fin.close();
}
`
 
    