[ROOT] Problem with string

From: Michal Lijowski (mlijowsk@artsci.wustl.edu)
Date: Wed Jul 17 2002 - 21:08:26 MEST


The program listed below produces output listed below the code.
My problem is a garbage after Charge5. When I comment two lines
TFile *FF = new TFile(.......);
gDirectory -> ls();
there is no garbage after Charge5.
The code is compiled under RedHat Linux 7.1, gcc 2.96-85 and root 3.03.06.
I appreciate any help.

Michal Lijowski

#include <TROOT.h>
#include <Rtypes.h>
#include <TFile.h>
#include <TDirectory.h>
#include <string>
#include <strstream>

// ----------------------------------------------------------------------

int main(int argc, char **argv)
{
   string  InDir, InFile;

   TROOT TestInt2String("Test Int2String", "Test Int2String");

   InDir = "/home/lijowski/cern/root/tutorials/";
   InFile = InDir + "hsimple.root";
   cout << " Input File " << InFile << endl;
   TFile *FF = new TFile(InFile.c_str(), "READ");
   gDirectory -> ls();

   strstream cc;
   Int_t iz = 5;
   cc << iz;
   string ZDir = "Charge";
   ZDir += cc.str();
   cout << " ZDir " << ZDir.c_str() << endl;
}

//------------------------------------------------------------------------------------------

Input File /home/lijowski/cern/root/tutorials/hsimple.root
TFile**		/home/lijowski/cern/root/tutorials/hsimple.root	Demo ROOT file with histograms
 TFile*		/home/lijowski/cern/root/tutorials/hsimple.root	Demo ROOT file with histograms
  KEY: TH1F	hpx;1	This is the px distribution
  KEY: TH2F	hpxpy;1	py vs px
  KEY: TProfile	hprof;1	Profile of pz versus px
  KEY: TNtuple	ntuple;1	Demo ntuple
 ZDir Charge5LA(LA



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