Maulrus Maulrus - 6 months ago 33
C++ Question

Is there any way to pass a std::string to a function that accepts a char* and changes its contents?

I'm trying to get back into programming, specifically console games. I'd heard that curses was good for that, so I found a curses tutorial and I'm getting into that. I'm using C++, and naturally I wanted to take advantage of std::string, but functions like

only accept char*. Is there any way to pass a string as a char*, or am I gonna have to forgo using C++ strings?


You can still use C++ std::string, but you'll have to copy the contents into a buffer (std::vector<char> would be good) and copy it back when using functions that expect a writable char* buffer.