(remember to add #include
vector
stringstream str1;
string str2;
cout << "setting String " << endl;
for (int j=0; j< 10; j++)
{
str1 << j;
cout << " str1 = " << str1.str() << endl;
str2 = "Hello ";
str2.append(str1.str());
SS.push_back(str2);
str2.clear();
str1.str("");
cout << " >> " << str2 << endl;
}
// to print out the string in order
vector
for(cii=SS.begin(); cii!=SS.end(); cii++)
{
cout << *cii << endl;
}
cout << endl;
// to print out the string in reverse order
vector
for (rii=SS.rbegin(); rii != SS.rend(); ++rii)
{
cout << *rii << endl;
}
No comments:
Post a Comment