Hi,
I'm trying to write code in C++ that loads .3ds files. .3ds files use floats in binary for vertex coordinates, but I don't know how to read them. I googled stuff for a bit, until it seemed like reinterpret_cas t was the way to do it, but this code
gives me this error:
invalid reinterpret_cas t from type `char*' to type `float'
Do any of you know how to read a float from a file? I will appreciate any help you can give me.
I'm trying to write code in C++ that loads .3ds files. .3ds files use floats in binary for vertex coordinates, but I don't know how to read them. I googled stuff for a bit, until it seemed like reinterpret_cas t was the way to do it, but this code
Code:
float readFloat(ifstream& file) {
char bytes[sizeof(float)];
for (int i = 0; i < sizeof(float); i++)
bytes[i] = file.get();
return reinterpret_cast<float>(bytes);
}
invalid reinterpret_cas t from type `char*' to type `float'
Do any of you know how to read a float from a file? I will appreciate any help you can give me.
Comment