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
The String Toolkit Library (Strtk) has the following solution to your problem:
#include
#include
#include
#include
#include "strtk.hpp"
int main()
{
std::deque flist;
strtk::for_each_line("file.txt",
[&flist](const std::string& line)
{ strtk::parse(line," ",flist); }
);
std::copy(flist.begin(),flist.end(),
std::ostream_iterator(std::cout,"\t"));
return 0;
}
More examples can be found in C++ String Toolkit (StrTk) Tokenizer.