C语言字节数组转float的几种方法
#include <stdio.h>#include <stdint.h>#include <string.h> typedef union a { unsigned char buf[4]; float value; } A; int main(int argc, char *argv[]) { unsigned char buf[4] = {0xA3, 0x70, 0x45, 0x41}; /* 法一 按字节赋值 */ float value; *((unsigned char *)&value + 0) = buf[0]; *((unsigned char *)&value + 1) = buf[1]; *((unsigned char *)&value + 2) = buf[2]; *((unsigned char *)&value + 3) = buf[3]; printf("value =……