I have a file such as:
1.0000000e+01 8.0123000e+01 1.0000000e+01 1.0000000e+01 1.0000000e+01
-1.0000000e+01 1.0000000e+01 1.0001110e+01 1.0000000e+01 1.0000000e+01
1.0000000e+01 1.0000000e+01 -5.0000000e+01 1.0000000e+01 1.0000000e+01
//... (repeated scientific numbers)
1 2 3 4
2 4 5 60
100 3 5 63
//... (repeated integer numbers)
I would like to read these numbers from a file in C++, but only the numbers which are in scientific format, so I need the code to stop when the number format changes. I also have this advantage that the float numbers come in 5 columns, whereas integers come in 4 columns.
So, what's the best way to do that in C++?
You could use strstr to search for "e+" in each line.
http://www.cplusplus.com/reference/clibrary/cstring/strstr/
If you wanted to be more fancy you use a regular expression library (such as boost::regex) which would also help you extract the strings from each line.