Use generic list to create list of strings
#include <iostream>
#include <cassert>
#include <list>
#include <algorithm> // For reverse
using namespace std;
int main()
{
string x[5] = {"asdf", "1234", "2345", "6789", "0000"};
list<string> list1(&x[0], &x[5]);
reverse(list1.begin(), list1.end());
list<string>::iterator i;
cout.precision(10);
for (i = list1.begin(); i != list1.end(); ++i)
cout << *i << endl;
cout << endl;
return 0;
}
/*
0000
6789
2345
1234
asdf
*/
Related examples in the same category