简体   繁体   中英

long long to byte array

I am sending a long long to a byte array with other stuff to a java server. When I convert the long back at the java end its not what I am expecting. I have tested the java converter but I ObjectiveC I thought that with it been low level would be as simple as this.

uint8_t *data = alloca(sizeof(longlong));
memcpy(&data[sizeof(Byte)+1],&theLong,sizeof(long long));

Is that right or am I on the wrong tracks?

也许...取决于字节序...在这里看看: http : //en.wikipedia.org/wiki/Endianness

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM