[ROOT] ofstream bug

From: David R. Relyea (relyea@SLAC.stanford.edu)
Date: Thu Aug 22 2002 - 02:33:45 MEST


The following code, when compiled outside ROOT, produces exactly the right
output:
4500
4900
5000
5606

In ROOT's cint, it produces:
4500

Huh?  I'm using 3.02/07, and I'd have expected this to work just fine...
Please tell me where ROOT's problem is.  Is it just a CINT thing?  This
seems too trivial for CINT to have a problem with...

David Relyea

#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <strstream.h>

void main() {

  int fab[4] = {4500,4900,5000,5606};
  int runnumber;
  ofstream es("energies.txt");
  int p=0;
  while(1) {
    runnumber = fab[p];
    p++;
    cout << runnumber << endl;
    if(runnumber < 4950) continue;
    for(int i=0; i<3; i++) es << runnumber << endl;
    if(runnumber == 5606) break;
  }
  es.close();
}



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:05 MET