I can't get either of these solutions to work. I tried this code:
Code:
char number[4];
sizeof(float)==4;
while (1)
{
number[0]=0x3F;
number[1]=0xC7;
number[2]=0xAE;
number[3]=0x14;
printf("%f\n", *((float*)number));
};
With this code I get a "declaration syntax error" on the sizeof line. I then tried this code instead:
Code:
char number[4];
float float_number;
sizeof(float_number)==4;
while (1)
{
number[0]=0x3F;
number[1]=0xC7;
number[2]=0xAE;
number[3]=0x14;
printf("%f\n", *((float_number*)number));
};
With this code I still get a "declaration syntax error" on the sizeof line, and I also get an "invalid expression" error on the printf line.
As for the second solution using memcpy, my compiler won't recognize it. It may have to do with the fact that I'm writing this code for an Atmel microcontroller.
Any further help is appreciated!