Skip to main content
edited body
Source Link
Israel Unterman
  • 13.7k
  • 4
  • 30
  • 35

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<char> ofor vector<int> 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.

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<char> of vector<int> 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.

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<char> or vector<int> 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.

Source Link
Israel Unterman
  • 13.7k
  • 4
  • 30
  • 35

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<char> of vector<int> 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.