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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -