Typecast cross-platform compatibility

Posted by kaykun on Stack Overflow See other posts from Stack Overflow or by kaykun
Published on 2010-05-16T05:36:19Z Indexed on 2010/05/16 5:40 UTC
Read the original article Hit count: 262

Filed under:

Hi, what I'm trying to do is append a binary integer into a string object. So far I have this:

int number = 5;
cppstring.append((char*)&number, 4);

It works fine on a x86 system with Windows, but some people are saying its not cross-platform and is unsafe. What is the preferred method to do this?

© Stack Overflow or respective owner

Related posts about c++