#include #include #include #include #define NOFCHANNELS 5 int fly(const char *fname = "trial_3.txt") { int npoints = 0; // http://www.cplusplus.com/reference/string/ std::string line; // http://www.cplusplus.com/reference/iostream/ifstream/ std::ifstream ifs(fname); while(1) { // http://www.cplusplus.com/reference/string/getline/ getline(ifs, line); if ( ! ifs.good() ) break; #if 0 /* 0 or 1 */ std::cout << "line = " << line << std::endl; #endif /* 0 or 1 */ // http://www.cplusplus.com/reference/iostream/istringstream/ istringstream s(line); std::cout << "entries[] ="; for(int i = 0; i < (NOFCHANNELS); i++) { double tmp = 0.0; s >> tmp; if ( ! s.good() ) { std::cout << std::endl; std::cout << "ERROR in line : " << (npoints + 1) << " : in column : " << i << " or " << (i + 1) << std::endl; break; } // if ( ! s.good() ) std::cout << " " << tmp; } // for(int i = 0; i < (NOFCHANNELS); i++) std::cout << std::endl; npoints++; } // while(1) #if 0 /* 0 or 1 */ std::cout << "npoints = " << npoints << std::endl; #endif /* 0 or 1 */ return npoints; } // int fly(const char *fname = "trial_3.txt")