Hi ROOTers, I'm trying to write some code to read out data from binary files. The data's in the form of short integers, so I have to read out blocks of two bytes at a time into a variable. My code is: #include <iostream.h> #include <fstream.h> int main() { char data_file[60]; short nevents; cout<<"Enter path to data file: "; cin>>data_file; ifstream data; data.open(data_file, ios::in|ios::binary); if(data.fail()) { cout<<"Failed to open file "<<data<<endl; return 0; } data.seekg(0,ios::beg); data.read(&nevents, 2); data.close(); cout<<"Number of events = "<<nevents<<endl; return 0; } This runs fine when compiled externally to ROOT, but when loading and running in ROOT I get the error message: root [2] main() Enter path to data file: /scratch/morgan/run1/Card1_0 Error: Can't call ifstream::read(&nevents,2) in current scope FILE:readtest.C LINE:21 Possible candidates are... filename line:size busy function type and name (in ifstream) filename line:size busy function type and name (in fstreambase) filename line:size busy function type and name (in ios) filename line:size busy function type and name (in istream) (compiled) 0:0 0 public: istream& read(char* s,int n); filename line:size busy function type and name (in ios) *** Interpreter error recovered *** >From looking at other ifstream/fstream related ROOTtalk messages, I assume this problem is something to do with CINT, but if so is there any other way to read this data in within ROOT (I want to use this code in a script eventually)? I'm using ROOT v3.01/06 on a Linux PC. Thanks, Ben Morgan. -- ------------------------------------------------------------------------------- Mr. Ben Morgan Postgraduate Student University of Sheffield Department of Physics & Astronomy Hicks Building Hounsfield Road Sheffield S3 7RH -------------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:40 MET