That's a bit more major than switching to consistent std::string usage, so I totally understand if you'd rather not do that [smile]
Here's what I'd recommend; just change your DXUDrawText calls to this DrawText function:
void DrawText(LPDXUFONT font, const std::string& text){ size_t buffersize = text.length() + 1; char* buffer = new char[buffersize]; std::copy(text.c_str(), text.c_str() + buffersize, buffer); // Pray that DXU doesn't throw exceptions. // If it does, see version 2 below. DXUDrawText(font, buffer); delete [] buffer;}// You should only need to use this version if you KNOW that the// DXU library throws C++ exceptions. I don't think it does, so// the above version should be OK.void DrawText(LPDXUFONT font, const std::string& text){ size_t buffersize = text.length() + 1; char* buffer = new char[buffersize]; std::copy(text.c_str(), text.c_str() + buffersize, buffer); try { DXUDrawText(font, buffer); } catch(...) { delete [] buffer; throw; } delete [] buffer;}
The basic problem is that the DXU font drawing code is asking for a C-string buffer that it can modify. I don't know for sure if it actually will modify the string, but I doubt it; in any case, better safe than sorry.
The trouble is, when we have a std::string and want to get a C-string from it, we get a C-string which isn't safe to modify. This is denoted by the fact that the value returned by c_str() is a const.
So we have a string we can't modify, but we have to give it to a function that demands permission to modify it. We're stuck.
(For the record, this is part of why I say the DXU code is garbage; the functions should take const strings at the very least, which would be denoted by the shortcut LPCTSTR rather than LPSTR. The DXU code is riddled with such inconsistencies and poor practices.)
The solution is to create a temporary copy of the string, in a special buffer that we have complete control over. That way, it's OK if the DXU code changes the string. Then, once the DXU code is done doing its thing, we clean up that temporary copy, and move on.