+ 3

How to make a string without '\0'?

A pointer was declared to have 2 chars and initialized but I still found '\0' as a third character.(please refer to the code). How to make a string without '\0'? https://code.sololearn.com/cRtza0op5CLI/?ref=app

29th Jan 2020, 2:48 PM
Chetan Satpute
Chetan Satpute - avatar
3 Respuestas
+ 4
When dealing with cpp unlike c stackoverflow looked at it https://stackoverflow.com/questions/42874699/stdstring-stops-at-0 my example is a bit different than Coder Kitten but also addresses the use of '\0' https://code.sololearn.com/c9Sr2TJsMcs9/?ref=app
29th Jan 2020, 4:25 PM
BroFar
BroFar - avatar
+ 4
Probably because the rest of the memory either contains or is initialised to 0 and 0 is the ASCII value of '\0'.
31st Jan 2020, 3:30 AM
Sonic
Sonic - avatar
+ 3
Another interesting thing to notice is that it doesn't only print 'yes' for index 2 but for all values.
29th Jan 2020, 3:15 PM
Avinesh
Avinesh - avatar