Recursion string to integer

my code is

#include
using namespace std;

int stoi(string s,int i,int number,int len)
{
if(i==len)
{
return number;
}

number=number*10+s[i]-'0';
stoi(s,i+1,number,len);

}

int main() {
string s;
cin>>s;
cout<<stoi(s,0,0,s.length());
return 0;
}

input 1234
output 1

@mohitmcanitt
hello Mohit,


it should be
return stoi(s,i+1,number,len);

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.