I'm currently having trouble with an assignment that is due in 50 minutes..
The instructions are to ask the user for a name or phrase then display the name/phrase backwards. He wants use to do it using a function (void). So far it can put a word backwards but it can't do a phrase (multiple words). It just repeats the first word, what am I missing?
#include <iostream>
usingnamespace std;
void reverse_String(string& greet, int n,int i){
if(n<=i){return;}
swap(greet[i],greet[n]);
reverse_String(greet,n-1,i+1);
}
int main()
{
string name;
cout << "Please enter a name or a phrase " << endl;
cin >> name;
reverse_String(name,name.length()-1,0);
cout<<"String after reversal: "<<name<<endl;
}