So I have an std::string
and have a function which takes char*
and writes into it. Since std::string::c_str()
and std::string::data(
I don't know what you intend to do with that string
, but if
all you need is a buffer of chars which frees its own memory automatically,
then I usually use vector
or vector
or whatever type
of buffer you need.
With v
being the vector, it's guaranteed that &v[0]
points to
a sequential memory which you can use as a buffer.