struct.pack

python struct.pack equivalent in c++

I want a fixed length string from a number just like struct.pack present in python but in c++. I thought of itoa (i,buffer,2) but problem can be that its length will depend on platform. Is there any way to make it independent of platform ? ...

python struct pack double

I want to convert -123.456 into a C double for network transmission in python. So I tried this: struct.pack('d', -123.456) I get this as a result: 'w\xbe\x9f\x1a/\xdd^\xc0' Obviously there is some hex in there, but what is with the w, /, and ^ sprinkled in there? ...