<分区>
因此,我尝试使用 atoi 函数将字符串转换为 int,但是我得到一个错误,指出参数类型 char 与类型 const char* 的参数不兼容。这是代码:
void evaluate(const char values[], string& codeMessage, string& result)
{
unsigned int i = 0;
while (i<codeMessage.length())
{
result+= values[atoi(codeMessage[i])];
i++;
}
}
因此,如果函数 evaluate({a,b,c,d}, "2331", result)
被调用,结果必须包含 "cdda"
。知道吗,我的代码有什么问题?谢谢