This snippet goes through a given directory, and prints out the path and name of each file it holds. What I want to do instead of print, is to store in a variable, and also keep count.
You should be able to use a standard container to store the paths, and a regular for loop over the iterators. If you cannot do this, I think you're over-reaching your current knowledge by too large an amount. Writing a simple loop and using a simple container are far more basic than what you're trying to do now.
You should be able to use a standard container to store the paths, and a regular for loop over the iterators. If you cannot do this, I think you're over-reaching your current knowledge by too large an amount. Writing a simple loop and using a simple container are far more basic than what you're trying to do now.
Turns out all I had to do was this:
int size;
int loopcounter;
vector<directory_entry> files;
copy(directory_iterator(ProjectDirectoryMain), directory_iterator(), back_inserter(files));
size=files.size();
for (int loopcounter=0 ;loopcounter<size;++loopcounter) {cout << files.at(loopcounter);}
You should either remove the 'int loopcounter' from the start of the code or remove the 'int' from the for loop. right now you're creating two variables with the same name. What's the value of loopcounter after the loop is done? ;)
Humble people don't refer to themselves as humble (W.R.T. "IMHO".)