What is wrong in this code of removing consecutive duplicates in a string

#include
#include
using namespace std;

void consecdup(char a[])
{
int j=0;
if((strlen(a)==0) or strlen(a)==1)
{
return;
}
for(int i=1;i<strlen(a);i++)
{
if(a[i]!=a[j])
{
j++;
a[j]=a[i];

	}
}     
a[j+1]=='\0';
return;

}

int main()
{
char a[1000];
cin.getline(a,1000);

consecdup(a);

cout<<a<<endl;

return 0;

}

hi @Subrat please share your code using CB IDE

@Subrat it should be a[j+1] = '\0';
image

1 Like

thank you so much Mam…

@Subrat dont forget to mark your doubt as resolved!