String remove duplicates

#include
#include
using namespace std;
void dup_char(char a[],int n,int i){

if(n==0){
	return ;
}
if(a[i]!=a[i+1]){
	cout<<a[i];
}
dup_char(a+1,n-1,0);

}
int main(){
char a[10],b[10];
cin>>a;
int n=strlen(a);

dup_char(a,n,0);

}
please correct my code

@tishya_goyal size of string can be upto 1000 and you have taken your char array size upto 10 only hence it is giving you run error. update your array size as 1000 and you are good to go.

1 Like

@tishya_goyal mark this doubt as resolved if you don’t have any further queries.

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.