#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(int argc, char **argv)
{
string c;
int k = 0, decval, i;
cout << "Please input your number starting from lowest value number to highest" << endl;
cin >> c;
//the for loop takes a backwards integer and makes it forwards.
for(i = 0; i < c.length(); i++){
decval += (c[i] - '0') * pow(10, k);
++k;
}
cout << decval;
return 0;
}
so my problem is when I input something like 564(wanting to get 465 in return) I get 462. I haven't been able to spot the logic error in the code. Note that I am both new to coding and stack overflow so please don't be too harsh. Any help would be greatly appreciated.