Duplicate character formatting

#include<bits/stdc++.h>
using namespace std;
string output="";
string duplicate_character(string input,int i)
{
output+= input[i];
if(input[i]==’\0’)
{
return output;
}

else if(input[i] == input[i+1])
{
	output+= '*';
}

return duplicate_character(input,i+1);

}
int main() {
string input;
cin>>input;
string ans = duplicate_character(input,0);
cout<<ans;
return 0;
}

It is not passing any test case but in custom test case it works just fine. Please help

hi @Rahulranjan916
ur code is absolutely correct… i manually tried it on all test cases, it’s working fine… maybe some compiler issues…

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.