Do/while loop not functioning correctly
<p>I'm having a problem getting my do/while loop to function properly.
This program runs good the first go-around, but when i enter 'y' when it asks if i would like to "tell more" the program just asks the user the question (not allowing me to enter a string) and then couts the statements. What am I doing wrong? and how do i get it to function properly?</p>

<pre><code>using namespace std;

int main()
{
    int i, numspaces = 0;
    char nextChar;
    string trimstring;
    string uc, rev;
    string answer;
    char temp;
    cout &lt;&lt; "\n\n John Acosta"
    &lt;&lt;" Exercise 1\n"
    &lt;&lt; "\n\n This program will take your string, count the number\n"
    &lt;&lt; " of chars and words, UPPERCASE your string, and reverse your string.";

    string astring;
    do {
        cout &lt;&lt; "\n\nTell me something about yourself: ";
        getline (cin, astring);

        trimstring = astring;
        uc = astring;
        rev = astring;

        for (i=0; i&lt;int(astring.length()); i++)
        {
            nextChar = astring.at(i); // gets a character
            if (isspace(astring[i]))
                numspaces++;
        }


        trimstring.erase(remove(trimstring.begin(),trimstring.end(),' '),trimstring.end());
        transform(uc.begin(), uc.end(),uc.begin(), ::toupper);

        for (i=0; i&lt;rev.length()/2; i++)
        {
            temp = rev[i];
            rev[i] = rev[rev.length()-i-1];
            rev[rev.length()-i-1] = temp;
        }

        cout &lt;&lt; "\n\tYou Entered: " &lt;&lt; astring
        &lt;&lt; "\n\tIt has "&lt;&lt;trimstring.length()
        &lt;&lt; " chars and "&lt;&lt;numspaces+1
        &lt;&lt; " words."
        &lt;&lt; "\n\tUPPERCASE: "&lt;&lt;uc
        &lt;&lt; "\n\tReversed: "&lt;&lt;rev
        &lt;&lt; "\n\n";


        cout&lt;&lt;"\n\nwant to tell me more? Enter \"y\" for YES and \"n\" for NO\n\n";
        cin&gt;&gt;answer;
        cout&lt;&lt;"\n";

    } while(answer == "y");                 //contiue loop while answer is 'y'; stop when 'n'

    {
        cout &lt;&lt;"\n Thanks. Goodbye!\n";     //when loop is done
    }

    return 0;
}
</code></pre>
