You do realise that std::string has a
c_str method that allows you to extract a C-style, null terminated string from it?
Here's an example usage:
if(keys == true){ std::string newCaption(caption); newCaption += (char)i; //See how easy it is to add stuff to a std::string delete [] caption; // Delete current caption caption = new char[newCaption.length() + 1]; //+ 1 for null terminal strcpy(caption, newCaption.c_str()); keys = false; break;}
The best solution, however, is to replace caption with a std::string and whenever you need a char *, just use the c_str() method. Better yet, make caption an
istringstream class and then you can add any thing to it, such as ints or floats etc, without having to use the nasty sprintf! Just call str() to get a std::string, and then call c_str() on that to get your C-style string (i.e. call str().c_str())
HTH