Take as input str, a number in form of a string. Write a recursive function to convert the number in string form to number in integer form. E.g. for “1234” return 1234. Print the value returned. is this a wrong approach

#include
using namespace std;

void string_to_int(char *input,char *output, int i,int j)
{
if(input[i]==’\0’)
{
output[j]=’\0’;
cout<<output<<endl;
}
int digit =input[i]-‘0’;
output[j]=digit;
string_to_int(input,output,i+1,j+1);

}
int main()
{
char input[100];
char output[100];
cin>>input;
string_to_int(input, output, 0,0);
return 0;
}

Hey @Srajanjaiswal
Your approach is not right. Check this out https://www.geeksforgeeks.org/convert-a-string-to-an-integer-using-recursion/

If your doubt is resolved please mark it as closed.