Whats wrong in this code, because while running it not give any output only, keep running in ide

#include
#include
using namespace std;
void removeDuplicates(string str,int i,int n){
//base case
if(str[i]==’\0’){
cout<<str<<endl;
}
if(str[i]==str[i+1]){
for(int k=i+1;k<n;k++){
str[k]=str[k+1];
}
}
removeDuplicates(str,i+1,n-1);
}
int main() {
string str;
cin>>str;
removeDuplicates(str,0,str.length());
return 0;
}

there are some logical errors in your code because of which it is running infinitely or giving Runtime error
(i) For C++ stl string, they are not terminated by the null characters, they are implemented differently, so here for comparing with null you should declare as char str[1001] and for taking input use "cin.getline(str, 1000);

(ii) NOW in your removeDuplicates function, inside base case print the string using for loop now as string array is used now.

(iii) Now while comparing if (str[i] == str[i+1]), the values you used replacing is incorrect, it should be like str[k-1]=str[k].
Also after the comparision update str[n-1] = β€˜\0’ because now this char is moved 1 index backward and we don’t need it again.
and the function call will be removeDuplicated(str, i, n-1) as there are still chances that current index β€˜i’ will match with furthur elements.

(iv)There will also be a else case if they are not equal which will call removeDuplicated(str, i+1, n) as current index i doesnot match so it is fine.

Feel free to ask if you still have any furthur doubt with logic or code.
Please mark this doubt as resolved to acknowledge me that you got it.

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.