   Char and int conversion problem in C++
  Hi therethis is probably a fairly simple problem but im a bit of a newbie so at the minute its beyond me.Im making a breakout clone and the levels are being loaded from files with the extension .lvl (its just a plain text file) Each level has a file eg Level 1 -> 1.lvl, im sure you get the idea.Now i was planning on having an int to hold the current level and then use an fstream to open the file and read in the stuff. The one problem im having is simply how to convert the int + the file extension to a char[]??Any help would be appreciated,cheers 
#include <sstream>// ...int level = 1;std::ostringstream sstr;sstr << level << ".lvl";// sstr.str() is now "1.lvl" ;  Ok thats cool, thanksbut one more thing, i was using fstream to open the file but it doesn''t seem to take a sstream or a string as a parameter. So is there a way to convert one of those into a char[] or something. Or should i be using a different method to read in the file.Thanks for your help Null and VoidCheers ;quote:Original post by ThompsyIsBonkers  So is there a way to convert one of those into a char[] or something. Or should i be using a different method to read in the file.Call the string''s c_str member function (sstr.str() becomes sstr.str().c_str()). See this page for more information on what you can do with strings. (I knew you were going to ask that . I should have handled it in my first reply...)   ;  You can convert a stringstream to a string with .str() and a string to const char* with .c_str(), so if you want to convert a stringstream to const char* then use .str().c_str(). ;  Haha a predictable newbie question then hahaThanks for your help man,its much appreciated ;  int level = 1;char filename[64];sprintf(filename, "%i.lvl", level);// the filename array is now "1.lvl" "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA 