Write a program to reverse a user entered string using recursion

Program : 2.2

---------------------------------------------------------------------------------------------------------------------

#include<iostream>
#include<string.h>
using namespace std;
int n;
void revr(int a,int b,string &s1)
{ if((a!=b)&&(a<b))
{
s1[n]=s1[a];
s1[a]=s1[b];
s1[b]=s1[n];
revr(a+1,b-1,s1); }
}
int main()
{
int l;

string s;
cout<<"Enter the string:\n";
getline(cin,s);
l=s.length();
n=l+1;
revr(0,l-1,s);
cout<<"The reversed string is:\n\n\n"<<s<<endl;
}

--------------------------------------------------------------------------------------------------------------------