Read them into a variable like you could have already done with the
short int
s:
float val;
file.read(reinterpret_cast<char*>(&val), sizeof(val));
You might even read them all at once into a buffer:
float *data = new float[SRTM_SIZE * SRTM_SIZE];
file.read(reinterpret_cast<char*>(data), sizeof(float) * SRTM_SIZE * SRTM_SIZE);
delete[] data;
But note that the values when read from the text file later and converted back to floating point might be slightly different. That applies especially when not printing with the full precision of the
float
type.
[EDIT]
Note also that your code produces an additional comma after the last column in the CSV file. Use something like this instead:
if (y)
meinFile << ",";
meinFile << height[x][y];
[/EDIT]