How can I recognize the last iteration in a C++ while loop?
<p>How would I make so that the last player name doesn't have a <code>,</code> so it's:</p>

<pre><code>Player online:
Jim, John, Tony
</code></pre>

<p>and not</p>

<pre><code>Player online:
Jim, John, Tony,
</code></pre>

<p>My code is:</p>

<pre><code>bool Commands::whoIsOnline(Creature* c, const std::string &amp;cmd, const std::string &amp;param)
{
Player* player = dynamic_cast&lt;Player*&gt;(c);

if (player)
{
    player-&gt;sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Players online: ");
    AutoList&lt;Player&gt;::listiterator iter = Player::listPlayer.list.begin();
    std::string info;
    int count = 0;

    while (iter != Player::listPlayer.list.end())
    {
        info += (*iter).second-&gt;getName() + ", ";
        ++iter;
        ++count;

        if (count % 10 == 0)
        {
            player-&gt;sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.c_str());
            info.clear();
        }
    }

    if (!info.empty())
        player-&gt;sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.c_str());
}

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