In my project there is a method which only returns a const char*
, whereas I need a char*
string, as the API doesn't accept const char*
.
Any idea how to convert between const char*
to char*
?
First of all you should do such things only if it is really necessary - e.g. to use some old-style API with char*
arguments which are not modified. If an API function modifies the string which was const originally, then this is unspecified behaviour, very likely crash.
Use cast:
(char*)const_char_ptr