intmain() { unionDoubleBytes unionData; unionData.d = 3.14159;// 你的 double 值 // 将 double 转换为字节数组 unsignedcharbyteArray[sizeof(double)]; memcpy(byteArray, unionData.bytes,sizeof(double)); // 打印字节数组的内容 for(inti = 0; i <sizeof(double); i++) { printf("%02X ",...
本文包含了C/C++中byte(unsigned char)类型与double数组互转的方法,参见本文的最后两个方法,亲测可行。 #include<vector>#include<iostream>#include<string.h>typedefunsignedcharbyte;typedefstruct{intprecession;doublevalue; }ConstantValue;byteint2Byte(intintVal);voiddouble2bytes(doubledata, byte* bytes);doubl...