Word list using strings

This is my homework assignment,
I can probably program myself out of a paper bag.
Any help would be appreciated.

Write a program that asks the user how many words he would like to save. Ask him for as many words as he stated he would give. After he gives you his last word, display each word on it’s own line. Use a vector to hold the words in string form. Use each of the functions described in class to edit the list, and display the amended list below the original.

Here's what I have so far. I dont think any of this is correct.

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>
#include <string> 
#include <vector>
using namespace std;


class Arr[] = { "Word1", "Word2", "Word3", "Word4", "Word5", "Word6", "Word7" };


int main()

{
	vector<string>list;

	cout << "How many words would you like to save?" << endl;

	
	
	list.push_back("Word 1");
	list.push_back("Word 2");
	list.push_back("Word 3");
	list.push_back("Word 4");
	list.push_back("Word 5");



	for (int i = 0; i < list.words(); i++) {
		cout << list[i] << endl;
	}


	system("pause");
	return 0;
}
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
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int nWords;
    string aWord;
    cout<<"how many words do you want to enter:";
    cin>>nWords;

    vector<string> words;

    for(int i = 0; i < nWords; i++)
    {
        cout<<"Enter world "<<i+1<<" : ";
        cin>>aWord;

        words.push_back(aWord);
    }

    /*Modify the words vector as you want*/

    /*print out the vector*/
    cout<<endl<<"The words you entered are:"<<endl<<endl;
    for(size_t i = 0; i < words.size(); i++)
        cout<<words.at(i)<<endl;

    return 0;
}
Topic archived. No new replies allowed.