Reputation: 25
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++;
}
I'm getting:
C:\Users\Anthony\Downloads\pack1.cpp|77|error: cannot convert 'std::basic_string<char>' to 'char*' in assignment|
I'm trying to go down backwards through 'x' and write each ascii code down as I go. The formula at the bottom is a hash. 'x' is a filename. I'll be unhashing it later. I need to run it through atoi().
Please help, as I do not know what to do. Everything else in the program is running fine, but as for this I'm a bit unsettled at the truthiness that this might be impossible. Please help, thank you.
Upvotes: 0
Views: 400
Reputation: 4055
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++;
}
Upvotes: 2