I'm trying to read in multiple files. The problem is that the names don't follow a logical sequence, so I can't simply "create" the filename for the next file by using a logical function. In fact, the only thing they have in common is that they're in the same directory.
Is there any way I can have the program automatically run through all the files in a specified directory? In the best case scenario, it would also be able to handle subdirectories and "know" when it's starting the next set of files. And, to top it off, would it be able to read only those files with a specified extension?
If anyone could help me with this, it would be greatly appreciated!
Late reply, but: thanks for the help! Found a good tutorial on msdn for using the Windows API to get this done.
However, I've run into a big problem. I've been testing the reader as a separate project to make sure I wouldn't mess anything up in my main program. Now, everything was working, so I copypasted my code into my main program (though as a function, not as main()). After getting a load of errors throughout my code, I spent half an hour trying to figure out what was going on. Most errors were syntax errors on comma's in parameter lists of my functions.
Turns out that commenting out the #include <windows.h> fixes everything (except my directory reader). I've never worked with this header before, but it seems odd to me that including a single header (from my own OS no less!) changes the entire syntax. What could be causing this and how can I get around it?
After some looking around, I've noticed that nearly all errors are on lines with the same variable, being a vector<vector<int>> used in many different places. It's not the only container of that type I use and it's not being used any differently than my other instances of such variables. In fact, most of the program runs using a vector<vector<vector<int>>> container.
The errors are mostly:
syntax error : missing ';' before '.' (When calling a .clear() on that variable)
syntax error : ')' (When passing that variable in a function; all variables are passed by reference, often as const as well. It's not the only variable being passed that way in that function call)
syntax error : '[' (When accessing specific elements using [i][j] notation. Again, not the only variable used that way)
Then a different series of errors appears in my validation part. This is basically a series of boolean operations, split up for readability and easier debugging:
error C3493: 'check' cannot be implicitly captured because no default capture mode has been specified (Line: check = (check && n1 != next[n2]);)
All of this works when I leave out <windows.h>. I have no idea what's going on.
Fixed: Apparently windows.h includes a file called WinDef.h, which defines a macro "near", which was also how the variable was called inside functions (passed by reference). Any lines near the use of the near variable had unexpected behaviour as a result.