Given a string str representing a string, the task is to convert the given string into an integer.
Input: str = “1234”
Input: str = “0145”
Approach: Write a recursive function that will take the first digit of the string and multiply it with the appropriate power of 10 and then add the recursive result for the substring starting at the second index. The termination condition will be when the passed string consists of a single digit. In that case, return the digit represented by the string.
Below is the implementation of the above approach:
- Convert a String to Integer Array in C/C++
- Convert given integer X to the form 2^N - 1
- Given a string and an integer k, find the kth sub-string when all the sub-strings are sorted according to the given condition
- Minimum number of given operations required to convert a string to another string
- Convert the string into palindrome string by changing only one character.
- Print reverse of a string using recursion
- Program for length of a string using recursion
- Convert Hexadecimal value String to ASCII value String
- Rearrange a string in sorted order followed by the integer sum
- Program to check if input is an integer or a string
- Rearrange a string in the form of integer sum followed by the minimized character
- Minimum cuts required to convert a palindromic string to a different palindromic string
- Check if a given string is a valid number (Integer or Floating Point) in Java
- Convert String into Binary Sequence
- Convert character array to string in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.