conversion string to char

Is any funciton to convert string to char*? not to const char*
In C++17 you can use str.data(), otherwise you can use &str[0].
@OP: What do you mean by "convert"?

- Do you want a non-const pointer to the actual character storage within the std::string object?

- Do you want to generate a new char array, that contains a copy of the character data from the std::string object?

What is it you want to do with that pointer, that it needs to be non-const?

EDIT: *Sigh* this is a duplicate of http://www.cplusplus.com/forum/general/236064/ . Please DON'T make multiple threads for the same question. You just waste people's time.
Last edited on
doing as Peter87 said is fine until you change its length. If you need to change its length, you need to copy it out to a C string and leave the object alone.
Topic archived. No new replies allowed.