I/O problems?

Daniel Barna (Daniel.Barna@cern.ch)
Fri, 8 Aug 1997 19:43:17 +0200 (METDST)


Hi!
I've read <A HREF="http://root.cern.ch/root/roottalk/0676.html">
Marc Mueller's question</A>. I tried about the same, and I failed
too. But if I create the 'ifstream' class with 'new', it seems to work,
while I don't want to reset the interpreter with the '.reset' command.
My macro is:

{
gROOT->LoadMacro("fstream.h");
TCanvas *c = new TCanvas("c", "The Hello Canvas", 400, 400);
const Int_t NSLICES=512;
Int_t h;
Int_t value;
TH1D *histogram[NSLICES];
Text_t hname[100];
for(h=0;h<NSLICES;h++) // creating histogram array
{
sprintf(hname,"h_%i",h);
histogram[h]=new TH1D(hname,hname,71,109.5,170.5);
}
ifstream *input_file=new ifstream("data");
while(1) // fill histograms
{
*input_file>>h>>value;
if(input_file->eof()) break;
histogram[h]->Fill(value);
}
return;
}

After running this macro I can draw the histograms in the command line:
histogram[100]->Draw();
But if I say '.reset' I get the following message:

*** Break *** segmentation violation

( 0) 0xc0d3ede0 StackTrace__11TUnixSystemFv + 0x28
[/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
( 1) 0xc0d3d8e8 DispatchSignals__11TUnixSystemF8ESignals + 0x150
[/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
( 2) 0xc0d3c5c0 SigHandler__F8ESignals + 0x28
[/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
( 3) 0xc0d407f8 sighandler__Fi + 0x58
[/afs/cern.ch/na49/library/local/ROOT/root/lib/libUnix.sl]
( 4) 0xc012f2e0 _sigreturn [/usr/lib/libc.1]

and so on. What's wrong with this macro?
Thanks
Daniel