I have a binary file that contains floats so that every 4 bytes are a float. I'm not sure how I can read in a way that every four bytes would be stored as a float so I can do whatever I need with it.
Here's my code:
int main()
{
float i;
std::ifstream inFile("bin_file", std::ios::binary);
while (inFile >> i)
{
std::cout << i;
}
inFile.close();
return 0;
}
In that case, it won't even enter the while loop unless I define i as a char. I guess that's because it reads 1 byte every time and can't store it as a float. Btw I've checked and the file opens.
Thanks!