c++ string pointer to char*

Started by
19 comments, last by Paul C Skertich 11 years, 7 months ago

Your code should work as long as [font=courier new,courier,monospace]someotherfunction[/font] takes a [font=courier new,courier,monospace]const char*[/font].

If the problem is that it takes a [font=courier new,courier,monospace]char*[/font] (but does promise not to write to the buffer), then you can use the const-correctness hack:someotherfunction( const_cast<char*>(data->c_str()) );//C++ style
someotherfunction( (char*)(data->c_str()) );//or C-style casting



You beat me to the chase Hodge. Const keyword guarantees it won't change unless specified.
Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

This topic is closed to new replies.

Advertisement