storing extracted characters in a vector of strings

Viewed 50

I should reasonably be able to store chars in a std::vector of strings, if the conversion is considered.

Here is the try:

vector<string> f (vector<string> input)
{
    vector<string> output;
    for (int i=0; i<input.size(); i++)                 // vector iteration
    {
        for (int j=0;j<input[i].size(); j++)           // string iteration
        {
            output.push_back(string(input[i].at(j)));  // access to characters
        }
    }

    return output;
}

input[i] is a string, and input[i].at(j) is a char; thus, I've converted it to string before pushing to vector<string>.

I'm wondering what's wrong with this approach. Especially, the compiler's error is undecipherable to me:

invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}' to 'const char*' [-fpermissive]

Edit:

f must work as follows.

Suppose there are 3 strings in the input vector: {abcd,efdr,loab}; then, the output shall extract all atormic characters like: {abcdefdrloab}

2 Answers
Related