I am trying to do a simple comparison to be able to do something if the file type read is a directory.
Sample code :
int main()
{
DIR *dir = opendir(".");
struct dirent *dirent = readdir(dir);
if (dirent->d_type == DT_DIR)
//do something
return 0;
}
Here is says:
DT_DIR
not initialised
When I try to use brackets around as such: "DT_DIR"
I get the following errors:
comparing pointer and integer
comparison with string literal results in undefined behavior
If I understand correctly I need to put DT_DIR
in a char
array? This is the first time I'm using these structs and functions.