emptying a vector and printing the string equivalent

hi, im trying to empty an int vector and replace it a sting, so far i have done this but its not working, any help would be appreciated

the final output should be "five four three two one one two three four five"

heres my code:

#include<iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
vector<int> a;
a.push_back(5);
a.push_back(4);
a.push_back(3);
a.push_back(2);
a.push_back(1);
a.push_back(1);
a.push_back(2);
a.push_back(3);
a.push_back(4);
a.push_back(5);

for(unsigned int i =0; i<a.size(); i++)
{

cout << a[i] << "\t";

}
cout << endl;

vector<string>b;
b.push_back("One");
b.push_back("Two");
b.push_back("Three");
b.push_back("Four");
b.push_back("Five");

for (unsigned int i = 0; i<b.size(); i++)
{
cout << b[i] << " ";
}
cout << endl;


for (unsigned int i = 0; i<=4; i++)
{
a.erase(a.begin());


cout << b[i] << " ";
}
cout << endl;



return 0;
}
I don't understand why you are erasing the vector. Try cout<<b[a[I]-1]
thanks man
Topic archived. No new replies allowed.