Trying to work with Vectors

Hello, I am trying to complete a school assignment in which a .txt is brought in, counted, and other junk. With this other junk, we need to count how many times each word is used and how many "special" words there are. Also, using a vector is a must. Therefore, I wanted to use a multidimensional vector; one holds each word, and another keeps track of how many times the word was used. I did look around, and is this the code that I will need to use:

vector< vector<int> > vec;

for (int i = 0; i < 10; i++) {
vector<int> row; // Create an empty row
for (int j = 0; j < 20; j++) {
row.push_back(i * j); // Add an element (column) to the row
vec.push_back(row); // Add the row to the main vector

If so, can someone explain it to me so I know how it works. If not, please inform me how I can go about accomplishing this with some explanation; for I really want to understand whats going on.
Thank you!
I hate homeworks because it alway force you to use least suitable container possible. I would use map<string, int> here, but, if forced to use vector, vector< pair<string, int> > will be good too.

Last edited on
Topic archived. No new replies allowed.