I used the following piece of code to read data from files as part of a larger program.
double data_read(FILE *stream,int code) {
char data[8];
Basically you can read gcc's message as guy you are looking for trouble, don't say I didn't warn ya.
Casting a three byte character array to an int
is one of the worst things I have seen, ever. Normally your int
has at least 4 bytes. So for the fourth (and maybe more if int
is wider) you get random data. And then you cast all of this to a double
.
Just do none of that. The aliasing problem that gcc warns about is innocent compared to what you are doing.