Skip to content

Instantly share code, notes, and snippets.

@mgarg1
Created September 18, 2014 02:37
Show Gist options
  • Save mgarg1/54ab9610b806e451eb06 to your computer and use it in GitHub Desktop.
Save mgarg1/54ab9610b806e451eb06 to your computer and use it in GitHub Desktop.
vector<char> toVector( const std::string& s ) {
string s = "apple";
vector<char> v(s.size()+1);
memcpy( &v.front(), s.c_str(), s.size() + 1 );
return v;
}
vector<char> v = toVector(std::string("apple"));
// what you were looking for (mutable)
char* c = v.data();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment