#include #include using namespace std; void writeReadData(int num=1000) { // write data to file //ofstream ofile("data",ios::binary); ofstream ofile("data"); for (int i=0; iRndm(); ofile << rnd << endl; } ofile.close(); // now read data from file //ifstream ifile("data",ios::binary); ifstream ifile("data"); TH1F* h = new TH1F("h","random",100,0.,1.); int nlines=0; while (ifile.good()) { float x; ifile >> x; if (ifile.eof()) break; //cout << "Entry:" << nlines << ": X " << x << " Y " << y << endl; h->Fill(x); nlines++; ifile.peek(); }; ifile.close(); h->DrawCopy(); }