c++ - A more elegant way to copy std::string into a vector<char> -


this question has answer here:

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

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -