[Solved] Cannot convert char to char


The error is on this line:

key[j]=words[index];

key is a

std::string key;

Therefore, key[j] is a char. words is a

std::vector<std::string> words;

Therefore, words[index] is a std::string.

You cannot assign a std::string to a char. C++ doesn’t work this way. Your code is equivalent to the following:

char a;
std::string b;

a=b;

It is not clear what your intent is here, but, anyway, this answers why you’re getting a compilation error.

solved Cannot convert char to char