It’s a program that uses recursion to convert string to int
The code always outputs 17 when it’s supposed to output 1234
and when I add a digit to that number it adds 1 to that output
for example if it’s supposed to output 12345 it outputs 18
#include <cstdlib>
#include <iostream>
using namespace std;
int convertToInteger(string numberStr)
{
if (numberStr.size()==0) return result;
convertToInteger (numberStr);
}
int main(int argc, char *argv[])
{
string numberStr("1234");
cout << numberInt << endl;
return 0;
}
You’re missing a
returnbeforeconvertToInt (numberStr);