Michal Lijowski <mlijowsk@artsci.wustl.edu> writes: > 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; > } > Hi Michal, I guess this is because you have an unterminated string inside your strstream object. cc << iz << ends; could work as you expect. -- Jiri
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:00 MET