int p; long unsigned int z;
while (i <= x.length())
{
const int a = x.length();
char* b;
b = x.substr(sizeof(a) - i, 1);
p = atoi(b);
z = (z + p + 3) * 3;
i++;
}
我得到:
C:\Users\Anthony\Downloads\pack1.cpp|77|error: cannot convert 'std::basic_string<char>' to 'char*' in assignment|
我正在尝试通过“x”向后走,并在我走的时候写下每个 ascii 代码。底部的公式是一个散列。 'x' 是一个文件名。我稍后会解散它。我需要通过 atoi() 运行它。
请帮忙,因为我不知道该怎么做。程序中的其他一切都运行良好,但至于这个我有点不安,因为这可能是不可能的。请帮忙,谢谢。
最佳答案
int p; long unsigned int z;
while (i <= x.length())
{
const int a = x.length();
string b;
b = x.substr(sizeof(a) - i, 1);
p = atoi(b.c_str());
z = (z + p + 3) * 3;
i++;
}
关于c++ - 如何让 atoi() 函数在字符串上工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27682386/