¿Cómo puedo hacer para que el último nombre del jugador no tiene una ,
por lo que es:¿Cómo puedo reconocer la última iteración en C++ while loop?
Player online:
Jim, John, Tony
y no
Player online:
Jim, John, Tony,
Mi código es:
bool Commands::whoIsOnline(Creature* c, const std::string &cmd, const std::string ¶m)
{
Player* player = dynamic_cast<Player*>(c);
if (player)
{
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Players online: ");
AutoList<Player>::listiterator iter = Player::listPlayer.list.begin();
std::string info;
int count = 0;
while (iter != Player::listPlayer.list.end())
{
info += (*iter).second->getName() + ", ";
++iter;
++count;
if (count % 10 == 0)
{
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.c_str());
info.clear();
}
}
if (!info.empty())
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.c_str());
}
return true;
}
para reconocer última iteración, compruebe el estado del bucle de rizo interior. –