title: Converting Int to char * and displaying on screen
body: <p>When I draw on the screen I want to show a dynamic text area for the game score. The only problem is that when I redraw the screen, it is not updated with the new score value and also there is garbled characters that appear after the zero. What I am trying to do is store an int that keeps the players score and increment that int and redraw the new value on the screen.</p>
  
  <pre><code>void drawText(SDL_Surface* screen,
  char* string,
  int posX, int posY)
  {
  TTF_Font* font = TTF_OpenFont("ARIAL.TTF", 40);
  
  SDL_Color foregroundColor = { 255, 255, 255 };
  SDL_Color backgroundColor = { 0, 0, 0 };
  
  SDL_Surface* textSurface = TTF_RenderText_Shaded(font, string,
      foregroundColor, backgroundColor);
  
  SDL_Rect textLocation = { posX, posY, 0, 0 };
  
  SDL_BlitSurface(textSurface, NULL, screen, &amp;textLocation);
  
  SDL_FreeSurface(textSurface);
  
  TTF_CloseFont(font);
  }
  
  char convertInt(int number)
  {
  stringstream ss;//create a stringstream
  ss &lt;&lt; number;//add number to the stream
  std::string result =  ss.str();//return a string with the contents of the stream
  
  const char * c = result.c_str();
  return *c;
  }
  
  score = score + 1;
  char scoreString = convertInt(score);
  drawText(screen, &amp;scoreString, 580, 15);
  </code></pre>