1 question not solved

i have solved multiply two numbers, but i am unable to solve convert string to integer please help

@agarwalarjit.agarwal hey,start traversing the string and convert each character to digit by subtracting ascii value 0 and than multiply it with 10 and add to ans which was initialise to 0 ,in this way number is formed.

#include<bits/stdc++.h> using namespace std; int print_integer(string s,int answer,int index) { if(index<0) return answer; else answer=answer*10+print_integer(s,answer,index-1); } int main() { string s; cin>>s; int n=s.length(); reverse(s,s+n); print_integer(s,0,n-1); return 0; }

this code is not working for the problem string to integer

@agarwalarjit.agarwal apne upr print integer function me use int me to change kia nho using - ‘0’.

please give correct code for this problem, i am stucked

@agarwalarjit.agarwal here is coe for reference:
https://ideone.com/MMkYCx