Convert a string to vector of string [duplicate]

  c++, string, vector

I have a problem, I want create a function that receives a string and save each letter in a vector of string, as I show to continue:

string s="My Name is";
vector<string> vs;

I want save each letter like this:

vs={"M","y"," ","N","a","m","e","","i","s"};

but with any word. And this is my code:

vector<string> phrases(string phrase){
    vector<string> sentence;
    for (unsigned i=0; i<phrase.length(); i++) {
        sentence.push_back(phrase[i]);
    }
return sentence;
}

but the code gives me a error. How can I fix this?

Source: Windows Questions C++

LEAVE A COMMENT