Significance of line

#include
#include
using namespace std;

void removenakli(char a[]){

int len = strlen(a);

int i = 0,j=1;
while (j<len){
    if(a[i]!=a[j]){
        i++;
        a[i]=a[j];
    }
    j++;
}
   a[i + 1] = '\0';

return;

}
int main() {
char a[1000];

cin.getline(a,1000);

cout<<a<<endl;

 removenakli(a);
 
cout<<a<<endl;  
  
  
return 0;

}

in this code what is the significance of this line ;-

a[i + 1] = ‘\0’;

The line a[i + 1] = '\0'; terminates the string by adding a null character at the end.

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.