c++ - A more elegant way to copy std::string into a vector<char> -
this question has answer here:
- converting std::string std::vector<char> 2 answers
i can't see find answer this, sorry in advance if there duplicate.
is there more elegent way of creating vector<char>
string
.
std::string s("i'm afraid. i'm afraid, dave."); std::vector<char> temp; (size_t x = 0; x < s.size(); x++) { temp.push_back(s[x]); }
thanks
construct range iterator this:
std::vector<char> temp(s.begin(), s.end());
Comments
Post a Comment