//string to int
#include
#include
using namespace std;
int stringtoint(char c[],int n)
{
if(n==0)
return 0 ;
int digit=c[n-1]-β0β;
int ans=stringtoint(c,n-1);
return ans*10+digit;
}
int main()
{
char a[]=β1234β;
int len=strlen(a);
cout<<stringtoint(a,len)<<endl;
}
It is only passing test case 1 and not other test cases.