Recursion duplicate character formatting question

GOT ONE CORRECT OUTPUT
#include<bits/stdc++.h>
using namespace std;
string * re(string * s,int i)
{if((*s)[i]==’\0’)
return s;
s=re(s,i+1);
if((*s)[i]==(*s)[i+1])
{
int k=i+1; char temp=(s)[i+1],curr=’’;
while(1)
{
(*s)[k]=curr;
curr=temp;
k++;
temp=(*s)[k];
if(curr==’\0’)
{(*s)[k]=curr;(*s)[k+1]=’\0’;break;}
}
}
return s;
}

int main() {
string s,*d;
cin>>s;
d=&s;
d=re(d,0);
cout<<s;
return 0;
}

hi satish
save ur code to online ide of coding block and post the link here

Can u explain me ur logic I am not getting what u r exactly doing

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.