Question: Using the Eclipse IDE, complete the recursive function ReverseString ( ) that takes in a string as a parameter and returns the string in reversed
Using the Eclipse IDE, complete the recursive function ReverseString that takes in a string as a parameter and returns the string in reversed order. The main function is provided to read a string from the user and call the ReverseString function. Assume the input string has a maximum of characters.
Hint: The program declares a pointer to a char array, which is directly manipulated by the ReverseString function. Move the first character to the end of the returning string and pass the remaining substring to the next ReverseString function call. Since C does not have a substring function, a substring can be formed by assigning a char pointer to the first character of the substring. A string must end with a null character
Ex: If the input of the program is:
Hello
the ReverseString function returns and the program outputs:
Reversed: olleH
Ex: If the input of the program is:
Hello, world!
the ReverseString function returns and the program outputs:
Reversed: dlrow olleH
Here is the starter code to import into Eclipse:
#include
#include
char ReverseStringchar stringToReverse TODO: Complete recursive ReverseString function here. int mainvoid char inStr; char resultStr; fgetsinStr stdin; strtokinStr
; Remove newline character from input. resultStr ReverseStringinStr; printfReversed: s
resultStr; return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
