A
Alexander Hunziker
Hello group,
I have a program that reads data from a binary file. I know that at some
known position in the file there are 12 4 bytes long floating point
numbers. Here's how I read them now:
float temptriangle[12];
fread(&temptriangle, 4, 12, fp);
This works quite nicely, however it does so only if sizeof(float) is 4,
otherwise I'll get garbage.
Is there a cleaner way of doing it? Reading 4 bytes from a file into a
floating point variable?
Thanks in advance for your help,
Alex
I have a program that reads data from a binary file. I know that at some
known position in the file there are 12 4 bytes long floating point
numbers. Here's how I read them now:
float temptriangle[12];
fread(&temptriangle, 4, 12, fp);
This works quite nicely, however it does so only if sizeof(float) is 4,
otherwise I'll get garbage.
Is there a cleaner way of doing it? Reading 4 bytes from a file into a
floating point variable?
Thanks in advance for your help,
Alex