Be gentle I am new at this but I need some help. I have to create a function and then use it recursively so that it reverses the string. This is my program so far..
Code:
#include <iostream>
#include <string>
using namespace std;
//PROTOTYPE
string Reverse(string s, int m); //reverse s from
//character at m-th position out to the end
// MAIN PROGRAM
int main ()
{
string s = "GeorgeWBush";
cout << Reverse(s,0) << endl;
return 0;
}
//IMPLEMENTATION OF PROTOTYPE
string Reverse(string s, int m)
{
string t = ""; //null string
if (m == s.length()-1)
{
return t + s[s.length()-1];
} else
return Reverse (s, m+1);
}
My dilema is that all it prints is the 'h', I know that there is more code to this but I am at a loss...any helpful hints or suggestions??