I have been toying with this problem for a bit and it is starting to annoy me. I cannot find the fault in this program. I believe the problem is due to the use of number[index]. Please help, thanks!
Code:#include<iostream> #include<string> #include<cmath> using namespace std; int main (void){ int base, index, total=0; string number; double counter = 0; cout << "\n\nPlease input base: "; cin >> base; cout << "\nPlease input number: "; cin >> number; index = (number.length() - 1); for(index ; index >= 0 ; index--){ total += pow(base,counter) * number[index]; counter++; } cout << endl << number << " in base " << base << " is " << total << " in base 10.\n"; return 0; }