This is correct. I got it.
memcpy ((void *) message.data(), zipcode.data(), zipcode.size()+1);

FYI.
--
Best Regards,
Roy Liu

On 2013-8-6, at 下午9:53, [email protected] wrote:

> I'm using PUB-SUB test with zmq.
> pls give me some advices. Thanks.
> 
> 
> My code:
> ---------------------
> std::string zipcode = "10001";
> zmq::message_t message(zipcode.size()+1);
> 
> // it's OK.
> memcpy ((void *) message.data(), "10001", zipcode.size()+1);
> 
> // it's Error, subscriber always receives bizarre code.
> memcpy ((void *) message.data(), &zipcode, zipcode.size()+1);
> ---------------------
> 
> 
> 
> --
> Best Regards,
> Roy Liu
> 

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to