why this code not giving desired output for removing consecutive duplicate strings?
Duplicate strings
this is because your input is a string, a string can have spaces
and hence it puts \0 at that one particular place and continues printing ahead
this codes takes input an array of characters which cannot have anything after spaces
you mean to say that strings doesn’t terminate with null character.
And how do we terminate a string?
STL uses iterators everywhere.
The null terminator is for a C string. Try not to confuse C++ into C.
Plus, this kind of conflict is sometimes handled differently by different compilers
in C++ it prints till it’s iterator is dereferenced
http://www.cplusplus.com/reference/string/string/end/
this is a helpful article u can go through regarding this