Convert string to integer


it shows segmentation fault

@naazsayma123 dry run your code once, it has many logical errors. like when you are extracting digit in line 8, you only specified the index, but forgot to write s in front of it. and you keep calling the function on the same string again and again without any changes, then how will it ever hit the base case? Use an index variable of type int to keep track of which character you are currently at.


it shows 0 as output

@naazsayma123 i have corrected it here

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.