I need to read in data files which look like this:
* SZA: 10.00
2.648 2.648 2.648 2.648 2.648 2.648 2.648 2.649 2.650 2.650
2.652 2.653 2.652 2.653
I would do something like this:
std::ifstream input("input.txt");
std::vector floats;
std::string header;
std::getline(input, header); // read in the "* SZA: 10.00" line
if(header_is_correct(header)) {
float value;
// while we could successfully read in a float from the file...
while(input >> value) {
// store it in the vector.
floats.push_back(value);
}
}
NOTE: header_is_correct(header)
is just an example, you will need to implement any error checking for that first line manually there.