I have VC++ 6.0 but can't seem to compile a simple chunk of code. I wrote this in Linux and it compiled just fine with gcc and with's BeOS's BeIDE. However, VC++ yells at me saying that "dirent.h" cannot be found.
Here's part of the code:
struct dirent* entry;
dir = NULL;
dir = malloc(sizeof(char) * 50));
// Open directory
if((dir_struct = opendir(dir)) == NULL)
printf("\nError opening directory structure\n");
while(entry = readdir(dir_struct))
// Build directory / path string
That's pretty straight-forward -- but dirent.h doesn't exist in Windows. So, do you know of any similar libraries for Windows that will allow me to retrieve the names of every file and every directory within a directory?
It is preferable if it does not use the Windows API as I want this code to be as portable as possible, but pretty much any method you can think of would be fine.
NOTE: I don't want this:
system("dir > dir.txt");
file = fopen("dir.txt", "r");
I really need some sort of C (or C++) routine that will allow me to do this.