Original Post
I'm using an older C function in C++ (my first mistake, I know :P). The first parameter requires a pointer to a character array, and I was just wondering whether I could use a stringstream or even a string rather than a raw character array to do the job. The problem is that ss.str().c_str() returns a const pointer. The same with s.c_str(). The function is expecting a non-const pointer. I can do the following:
const_cast<char*>(ss.str().c_str());
const_cast<char*>(s.c_str()); But to me that seems dangerous and probably won't even work correctly. Is there a good way to handle this that I've overlooked?