Approach Issue With Recursion

#include<bits/stdc++.h>
using namespace std;
void replaceChararcter(char *str,int i =0){
if(str[i]==’\0’ or str[i+1]==’\0’){
return;
}
if(str[i]==str[i+1]){
int j = i + 1;
for (; str[j] != β€˜\0’; j++){
str[j] = str[j+1];
}
replaceChararcter(str,i+1);
}
else{
replaceChararcter(str, i + 1);
}
}
int main()
{
char *arr = new char [100];
cin >> arr;
replaceChararcter(arr);
cout<<arr<<endl;
}

This is the code I wrote and Tried to copy link from Coding Blocks IDE but it did not copy . Kindly Let me know why is this approach wrong???

hey @NimeshJohari02 your code isn’t readable here
You can share this code using ide.codingblocks.com

  • A special url will be generated, share that url with me

i have corrected your code->


from next time try to share code as i have told above.

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.