I have a double converted to a unsigned char array. For example for value 1, the array becomes {64, 240, 0, 0, 0, 0, 0, 0}. Now I tried to convert the array back by using the following code, but all I got was crapy values...
double* pdfOutput = (double*)malloc(sizeof(double));
memcpy(pdfOutput, pInputArray, sizeof(double));
Would you please let me know where the problem is? Thanks.
Edit: The pInputArray is generated by LabVIEW. Basically what I am trying to do here is to make a program talking with a LabVIEW VI. So I don't have the control of the input array...
The simple way to do what you ask is to write:
double pdfOutput = *(double*)pInputArray;
but this will yield just the same results as your code. In other words, reinterpreting the char array that you have does not result in the double value that you expect. You need to look into the source of the char array. The code that is creating the char array is where I would expect the problem to be. To solve your problem you need to understand what the LabVIEW code is doing.