C convert unsigned char array to float array

二次信任 提交于 2020-06-17 09:42:07

问题


Is there a way to convert unsigned char array to float array without dereferencing each element of uchar array?

unsigned char* arr1 = malloc(sizeof(unsigned char) * 3);
float* arr2 = malloc(sizeof(float) * 3);

*arr1 = 3;
*(arr1 + 1) = 55;
*(arr1 + 2) = 213;

*arr2 = (float)(*arr1); // 3.0
*(arr2 + 1) = (float)(*(arr1 + 1)); // 55.0
*(arr2 + 2) = (float)(*(arr1 + 2)); // 213.0

来源:https://stackoverflow.com/questions/62136164/c-convert-unsigned-char-array-to-float-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!