Adam Turner

Adam Turner

  • NA
  • 60
  • 0

C++ is fun, monkey fun.

Oct 19 2008 1:39 AM
map listOfPlayers;

extern "C" bool R_CONTROLLER_API CreatePlayer(int num)
{
Player * Player1 = new Player(num);
listOfPlayers[num] = Player1;
return true;
}
extern "C" R_CONTROLLER_API char *ListPlayers()
{

static char string2return[500];
*string2return=0;
for( map::iterator i=listOfPlayers.begin(); i != listOfPlayers.end(); i++)
{
strncat(string2return, "test " + (*i).first, __min( 20, 500-strlen(string2return)) );
//params: char array, char array to append, number of chars to append
//__min returns the lesser of 2 numbers
}
return string2return;
}
The code above compiles fine, and CreatePlayer() works great, but the problem I'm having is in ListPlayers(). When invoked, the only thing I get back from the function is "est " with no 't'. I really suck with C++, so I'd appreciate the help!

Answers (4)