TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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!
Reply
Answers (
4
)
associative arrays in C++ for any class type?
How to Create Dialog Boxes in VC++6.0