#include #include #include using namespace std; // Read in any number of words (not // necessarily all on the same line) // and then when the input ends, write // them back out, one per line. // This version has the added complexity // of going by way of an old-fashioned // C array of char pointers, like the // exec procedures need, rather than just // sticking with the nice C++ vector of // strings. int main(int argc, char* argv[]){ string s; vector v; while(cin >> s){ v.push_back(s); } char **a = new char*[v.size()+1]; if(!a){ cerr << "couldn't allocate main array" << endl; return 1; } for(int i = 0; i < v.size(); i++){ a[i] = new char[v[i].size()+1]; if(!a[i]){ cerr << "couldn't allocate char array" << endl; return 1; } v[i].copy(a[i], v[i].size()); a[i][v[i].size()] = 0; } a[v.size()] = 0; for(int i = 0; ; i++){ if(!a[i]){ return 0; } cout << a[i] << endl; } }