Program won't run

I have a program that I made that used to run perfectly; there were no problems. This was until I updated code::blocks to 12.11 (It was like 10.05 or something like that before). Now, it still compiles with no errors but shuts off. Using debug, I found that the problem has something to do with it displaying font (not sure best how to word that). Anyways, to get it to work, I had to comment out two sections of coding which are:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if (SDL_GetTicks() - Frame_Time2 >= 1000)
        {
            Average_FPS = ( FPStype == FPS_Float ) ? FramesDrawn / ( ( SDL_GetTicks() - Frame_Time2 ) / (float)1000 ) : FramesDrawn;
            FramesDrawn = 0;

            char* message;

            ostringstream asdf;
            asdf<<"FPS: "<<Average_FPS;
            strcpy(message,asdf.str().c_str());

            FPS = TTF_RenderText_Solid(font,message,TextColor);
            Frame_Time2 = SDL_GetTicks();
        }


and

1
2
3
4
5
6
7
8
9
10
11
12
void Game::DisplayScore()
{
    char* message;

    ostringstream asdf;
    asdf<<"Coins: "<<Score;
    strcpy(message,asdf.str().c_str());

    score = TTF_RenderText_Solid(font,message,TextColor);

    apply_surface(SCREEN_WIDTH - score->w,0,score,screen);
}


Does anyone have any idea how I could recode those so the program works again?

Note:
The program starts up but then when it gets to one of those snippets, or whatever you would call them, the "[name] has stopped working" box pops up and it returns either 3 or 255

Edit:
I was actually able to fix this by changing chat* to char[100] is both occasions; however, I have another problem. The same thing happens whenever the game ends (whether it be from hitting the X, pressing esc, winning, or losing). The only command I use to quit the game in any instance is exit(0);. Also, how can I set the program's search directories for the images/files that it uses so that I can run it by clicking the application itself?
Last edited on
bump
1
2
char* message;
strcpy(message,asdf.str().c_str());
`message' points to garbage, you shouldn't write there.
Topic archived. No new replies allowed.