我想创建一个嵌套循环,循环遍历动态分配的数组(故事)找到字符“*”,并用来自另一个动态分配的数组(user_input)的信息填充这个字符所在的位置。然后将这个替换信息存储在一个新的动态分配的数组中,称为body to be cout。这是错误:
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
There is no context in which this conversion is possible
谁能告诉我我做错了什么?这是我的代码:
void create_story(string & user_inputs, string *story, int num_lines,
string **body)
{
*body = new string[num_lines];
for (int i = 0; i < story[i].length; i++)
{
if (story[i] == "*")
{
body[i];
}
for (int j = 0; j < story[i].length(); j++)
{
if (story[i][j] == '*')
{
cout << "I found it at character number: " << i;
*body[i] += user_inputs;
}
else
{
body[i] += story[i][j];
}
}
}
}