With the subscript operator [] you can only access one element from the string and you need to write more than one digit to the string ('A' -> "97"). To do that you need to convert the char value to a literal with std::to_string().
The simples solution is to use a second string as output, then you don't get in trouble with the indexing of the input string when you need to resize the string.
std::string str = "abc";
std::string out;
for(auto a : str )
{
out.append(std::to_string((unsigned int)a));
}
std::cout << out << std::endl;