Exercise from Accelerated C++
You could cut your code in half if you used a map:

typedef   std::map&lt;std::string, unsigned int&gt; Map;

Map tMap;
while(std::cin &gt;&gt; word)
{
    // When accessing a map with `[]` If the value does not exist
    // it is created and initialized to zero.
    //
    // The plus plus then increments the stored value
    tMap[word]++;
}

// Iterate through map and print frequency


Couple other notes from the code you have:


After unique_words.push_back(words[0]); you can start the i loop at index 1 instead of 0.
When checking for uniqueness in the first pair of loops, once you determine uniqueness to be false you can stop looping for that word: while(j &lt; unique_words.size() &amp;&amp; isUnique) ...