/* University College London P&A Dept Course in C/C++ 3C59 | all rights reserved 2000 | | Example: File I/O | | Simple program to demonstrate the use of file iostreams | to read some ThreeVectors fron a file | | Author: P.Clarke */ #include #include #include "../util/ThreeVector_secondgo.h" int main() { // Open file and check it opened OK std::ifstream myInputFile ("threevec.dat"); if ( !myInputFile ) { std::cerr << "Error: unable to open input file!" << std::endl; return 1 ; } // Read each line at a time while ( myInputFile ) { float x=0,y=0,z=0 ; myInputFile >> x >> y >> z ; if( ! myInputFile ) break ; // added to stop repeat of last line ThreeVector vec ; vec.initialise( x, y ,z ) ; vec.dump( ) ; } return 1 ; }