1
in ASCII table is unprintable character (start of heading - SOH). When printing it, your program will just skip over those (well, probably - ASCII is not guaranteed in any C++ program).
what's going in the memory?
In memory, you still have those 1
at every spot.
It looks like this:
1 119 111 1 114 108 1 1 100 0 // decimal values, assuming ASCII
SOH w o SOH r l SOH SOH d NUL // char representations
Is it really a good solution ?
Not really. char 1
might be printed differently on some systems. strlen()
will return full length of string, including those SOH characters, rather than number of printed characters (which one might expect). Iterating over this string will yield weird values. In general, working with this string later will be a mess.
It kinda works, for now, but you should probably truly remove characters instead of just replacing them with unprintables.