C++ examples for STL:vector
Storing Strings in a Sequence, Use a vector for array-like storage of your strings.
#include <string> #include <vector> #include <iostream> using namespace std; int main() {/*from www.j a v a 2 s .c o m*/ vector<string> v; string s = "one"; v.push_back(s); s = "two"; v.push_back(s); s = "three"; v.push_back(s); for (int i = 0; i < v.size(); ++i) { cout << v[i] << '\n'; } }