In remove duplicates?

in remove duplicates?
is it necessary to do – a[prev+1]=’\0’ as the code is running perfect without it ??

@mehulbhandari358 if you are using strings then there is no need for that.
if you are working with char arrays then you should do that to avoid any garbage value getting printed.

why with string it is perfect

Because string is a container of characters and outputs only those characters which are inside it, while char array prints all characters till it finds a null(\0).

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.