I'm really not sure what you're trying to get to but you are getting a null the four characters... however you do not have a string, as It has been pointed out, you're missing the null terminator; anyway, if you pass that pointer to any function that's supposed to take a string, it will only read an empty string...Oh, by the way, you can do something like this (3rd version)

Share this post

Link to post

Share on other sites

Sorry, I should have explained myself. I''m forming messages to pass through my pluggable factory. The factory will be able to accept both enumerated messages and string messages. To accept string messages I make the first value NULL (Where the message ID would normally be).

The only reason I asked this question is that my map.find() seemed to be failing and I was thinking that it was because I was getting the data assignment wrong.

I dont bother with a trailing null as it''s really not needed (the find can compare structures of binary data so should be able to do unterminated strings as well...

As it turned out I was incorrectly creating the registration token by not prepending it with the leading NULL.