Vector is not clearing : <p>I have created a function that gets a series of guesses (a sequence of colors) from a user and puts them in a vector, and this function is called within a while loop in main().</p>

<p>Each time it is called by the while loop, the guess should be cleared before being refilled with inputs. However, within the second loop, entering a color I entered during the first loop activates my error message ("Invalid or repeated color entry..."), suggesting that the vector was not successfully cleared.</p>

<p>I've tried to clear it with a space, various strings, etc., but nothing seems to clear it. What am I missing?</p>

<p>Function:</p>

<pre><code>void getGuess(vector&lt;string&gt; &amp;currentGuessPegs, vector&lt;string&gt; &amp;colorChoices, int maxPegSlots) {

string input; // stores input temporarily

// ---clear previous guess---
for (int i = 0; i &lt; maxPegSlots; i++) {
    currentGuessPegs[i] == "";
}

// ---prompt player for each peg guess and store in currentGuessPegs---
for (int i = 0; i &lt; maxPegSlots; i++) {
    cout &lt;&lt; "Peg " &lt;&lt; i+1 &lt;&lt; ": ";
    cin &gt;&gt; input;

    while (find(currentGuessPegs.begin(), currentGuessPegs.end(), input) != currentGuessPegs.end() // Loops if color entry has already been used
        || find(colorChoices.begin(), colorChoices.end(), input) == colorChoices.end()) {         //  or is an invalid choice

        cout &lt;&lt; "Invalid or repeated color entry. See color choices and re-enter a color you have not used.\n";
        cout &lt;&lt; "Peg " &lt;&lt; i + 1 &lt;&lt; ": ";
        cin &gt;&gt; input;
    }

    currentGuessPegs[i] = input;
}
}
</code></pre>

<p>And here is my call to the function from main():</p>

<pre><code>// ---get and check guesses until maximum # of guesses is exceeded or solution is guessed---
while (guessCount &lt; maximumGuesses &amp;&amp; solutionGuessed == false) {
    getGuess(currentGuess, colorOptions, numberOfPegs); // get the guess
    solutionGuessed = checkGuess(currentGuess, solution, numberOfPegs, red, white); // check the guess; returns true if solution was guessed

    cout &lt;&lt; "r: " &lt;&lt; red &lt;&lt; "   w: " &lt;&lt; white &lt;&lt; endl &lt;&lt; endl;

    guessCount++;
}
</code></pre>
