Elysia, very nice but your code does not compile and it's not like the original code that actually read an external file into vector strings. Dimensioning vector is next runner up but right now it's about vector strings. I had to drop the dimension thing for a minute.
How about this... I been very close it seems... This is what I been trying to do when using the iterator, but it keeps dumping the iterator template on me as an error at this block of code.
Code:
template<typename _InputIterator, typename _OutputIterator>
inline _OutputIterator
__copy_aux2(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, __false_type)
{ return std::__copy(__first, __last, __result,
std::__iterator_category(__first)); }
Code:
#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
#include <vector>
#include <iterator>
using namespace std;
int main()
{
vector<string> v_S;
ifstream in("unsorted.txt");
string word;
while(in >> word)
v_S.push_back(word);
cout << "\n Success, words are sorted from a textfile:" << "\n\n";
sort( v_S.begin(), v_S.end() );
for(int i = 0; i < v_S.size(); ++i)
cout << v_S[i] << "\n";
cout << "\n\n ... but how do I save it to a textfile?" << "\n";
ofstream outfile("sorted.txt", ios::out | ios::binary); // < =====
ostream_iterator<char> I_O(outfile, '\0');
copy(v_S.begin(), v_S.end(), I_O);
cin.get();
return 0;
}