// // I/O example program // Emiliano.Mocchiutti@ts.infn.it // #include #include using namespace std; // // this program open an existing text file with 8 columns // it reads the data and print the first file rows on the STDOUT // int main(){ ifstream in; in.open("myData.dat"); // we assume the filename on the disk is "myData.dat" float a1,a2,a3,a4,t1,t2,t3,t4; int nlines = 0; bool forever = true; while ( forever ) { in >> a1 >> a2 >> a3 >> a4 >> t1 >> t2 >> t3 >> t4 ; if ( !in.good() ) break; // cannot read properly the file, end the loop if (nlines < 5) cout << a1 << " " << a2 << " " << a3 << " " << a4 << " " << t1 << " " << t2 << " " << t3 << " " << t4 << endl; nlines++; } cout << " found " << nlines << " points \n"; in.close(); return 0; }