Demonstrating the STL vector push_back functions
#include <iostream>
#include <cassert>
#include <vector>
#include <string>
#include <algorithm> // for reverse
using namespace std;
int main()
{
string s("qwer");
vector<char> vector1(s.begin(), s.end());
vector<char> vector2;
vector<char>::iterator i;
for (i = vector1.begin(); i != vector1.end(); ++i)
vector2.push_back(*i);
for (i = vector2.begin(); i != vector2.end(); ++i)
cout << *i;
return 0;
}
/*
qwer
*/
Related examples in the same category