Hello,
I'm using some code similar to what was discussed back in this
thread.
Except this time I'm using a string, rather than an int.
I've been reading C++ docs such as
http://www.cplusplus.com/reference/cstdio/sprintf/
http://gribblelab.org/CBootcamp/9_Strings.html
And feel like what I should be doing is something like this
char playerNameText[256] = "";
sprintf(playerNameText, "%s", player.getPlayerName() );
agk::SetTextString(551,playerNameText);
player.getPlayerName() is a std::string
When I inspect it in my debugger it has the right value in it.
But when it shows up on the screen it ends up being a value like "*/!" or other non standard extended ascii characters.
When I do this it works fine:
char playerNameText[256] = "";
sprintf(playerNameText, "%s", "Player Name");
agk::SetTextString(551,playerNameText);
When I do this it does not:
char playerNameText[256] = "";
std::string pName = player.getPlayerName();
sprintf(playerNameText, "%s", pName);
agk::SetTextString(551,playerNameText);
But if I inspect the pName variable it has the right value before and after?
So I don't quite understand how its going from a string like "Charlie" to "^@2" .. usually 3 digits ironically?
I thought it was the %s but the documentation seems to say thats for a string, I also tried %c and that only does 1 character (and the wrong one at that).
Int's continue to work fine?
Any insight what I'm doing wrong?
Thanks!