There are many ways you can do this:
Code:
for (vector<string>::reverse_iterator i = PathOutput.rbegin(); i != PathOutput.rend()(); ++i)
{
fout << *i << " ";
}
Or use the reverse_copy function:
Code:
#include <algorithm>
#include <iterator>
...
std::reverse_copy(PathOutput.begin(),PathOutput.end(),std::ostream_iterator<std::string>(fout," "));
Or use the forward copy function but with reverse iterators instead:
Code:
#include <algorithm>
#include <iterator>
...
std::copy(PathOutput.rbegin(),PathOutput.rend(),std::ostream_iterator<std::string>(fout," "));
Or you could reverse the order of the elements in the vector first and then use a traditional begin->end output loop:
Code:
#include <algorithm>
...
std::reverse(PathOutput.begin(),PathOutput.end());
for( vector<string>::iterator i = PathOutput.begin(); i != PathOutput.end(); ++i )
{
fout << *i << " ";
}
Etc, etc, etc... I can go on and on and on...