how to think about converting string to an integer using recursion.
Recursion:-convert string into integer
You can directly convert any string having Integers into integer by using stoi(string) function which return integer
string s = 456;.
int n = stoi(s);
now n will be equal to 456;
By recursion you will have to take all the digits one by one and then you will have to accumulate them all.
For taking each digits do s[i]-‘0’ to get the integer and accumulate it by multiplying them by power of 10.
I am not able to understand this question,can any elaborate it with other test case.
please provide question link
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.