Description
#39 I googled and found this question. Yeah, it's my question too!
I really need my c program to be compiled as it's needed for a group project. When I compile I face this error:
error: 'struct dirent' has no member named 'd_type'
How can I solve this problem?
I am using windows 10. I need it for c programming language.
` struct dirent *dir;
DIR *pDir = opendir(path);
if (pDir) {
while ((dir = readdir(pDir)) != NULL) {
if (dir->d_type == FILE_FLAG) {
String filename = malloc(sizeof(char) * strlen(dir->d_name));
strcpy(filename, dir->d_name);
result[resSize++] = filename;
}
}
closedir(pDir);
}`
This is my struct dirent in direct.h:
struct dirent { long d_ino; /* Always zero. */ unsigned short d_reclen; /* Always zero. */ unsigned short d_namlen; /* Length of name in d_name. */ char d_name[260]; /* [FILENAME_MAX] */ /* File name. */ };
Edited: This post helped me to solve this problem, but is there a more neat way to solve it?
https://stackoverflow.com/questions/5530933/dirent-h-in-visual-studio-2010-or-2008