Hi all...
I'm trying to print text to the screen that displays the players name. I'm NOT using a console app, I'm using WIN32 API windows app. And I'm coding with VC6++.
What I've got so far for this part is a player struct that has player variables...
struct Player
{
int ID;
std::string PlayerName;
int Points;
etc...
}player[10];
Then I have a file that stores the actual data...
void PlayerData()
{
player[0].ID = 0;
player[0].Name = "Chris";
etc...
}
Now when I try to print it out to window I don't get compiler or linker error, but I get either gibberish or the program crashes.
the code I use to print to the screen is this...
HDC hdc;
char buffer[80];
hdc = GetDC(G1.hWnd);
SetBkColor(hdc, RGB(0, 0, 0));
SetTextColor(hdc, RGB(255, 255, 255));
sprintf(buffer,"ID: %d, %s has %d total points", player[0].ID, player[0].Name, player[0].Points);
TextOut(hdc, 5, 200, buffer, strlen(buffer));
ReleaseDC(G1.hWnd, hdc);
I tried taking out the string to see if the rest worked and the ints worked fine. I even tested the whole formula in a console app using cout and that worked so I've come to the conclusion that the std::string data type isn't compatible with either sprinf or TextOut.
If anyone could help I'd be incredibly grateful...
Thanks in advance...
Edited by - Alien Tesh on June 12, 2001 12:16:32 AM
Edited by - Alien Tesh on June 12, 2001 12:17:06 AM
Edited by - Alien Tesh on June 12, 2001 12:18:21 AM
Edited by - Alien Tesh on June 12, 2001 12:21:47 AM