#include <string>
#include <vector>
#include <iostream>
#include <istream>
#include <ostream>
#include <iterator>
#include <sstream>
#include <algorithm>
usingnamespace std;
int main()
{
int x = 0;
string str;
cout << "Enter name as Last, First I. " << endl;
cin >> str;
// construct a stream from the string
stringstream strstr(str);
// use stream iterators to copy the stream to the vector as whitespace separated strings
istream_iterator<string> it(strstr);
istream_iterator<string> end;
vector<string> results(it, end);
// send the vector to stdout.
ostream_iterator<string> oit(cout);
copy(results.begin(), results.end(), oit);
cout << "Rearranged name: " << endl;
cin >> x;
}
That is what I have so far but it just exits and I used an example I found online as a sort of template, I have the program running with no errors, which is a good start for me. However the program exits almost instantly after typing in my name, how can I make it display the output name rearranged in teh right order?