trial and error, emphases on error

Trying to convert from std::string to char*

Using const_cast Operator

We know that both string::c_str or string::data functions returns const char*. To get a non-const version, we can use the const_cast operator, which removes the const attribute from a class. This works in constant time as no copying is involved.

Please note that this approach will give us direct access…