ilejncs at narod.ru
Wed May 4 13:54:03 CEST 2011
>> What I don't understand is why Pieter confirmed that
>> the code pretty much like quoted is valid and "s[msg.length()] = 0;" makes sense.
>> The only way to explain is to assume 0 is present somewhere after a message.
>> In this case strcpy is safe, though string must be properly terminated after copy.
>> Again, it is just curiosity - I want portable data formats and applications do not crash ;)
> s[msg.length()] = 0 is standard C boilerplate for "If the
> message has no \0 termination, stick one at the end of the buffer just in
you are right, though original Pieter's explanation
> Why we do this
> data[message.size()] = 0
Precisely to create an ASCIIZ string from a 0MQ string.
sounds somewhat different.
More information about the zeromq-dev