1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <iostream> using namespace std; int main() { typedef char string_20[20]; int num_words; cout << "How many words? " << endl << ">>"; cin >> num_words; cout << endl; string_20 *words = new string_20 [num_words]; for(int i=0 ; i<num_words; i++){ cin.clear(); cin.sync(); cout << "your word#" << i+1 << ": "; cin.getline(words[i], sizeof(string_20)); } cout << endl; cout << "print words:" << endl; for(int i=0 ; i<num_words; i++) cout << words[i] << " "; cout << endl; delete[] words; system("pause"); return 0; } |
Direct link: https://paste.plurk.com/show/789850