Several solutions to this problem, depending what you want to do.
I will mention only two:
 - solution1. Use sprintf to create the histogram name from the loop index
 - solution2. Create an interator. Example
{
   gROOT->Reset();
   TFile f("marek.root");
   f.Read();  // read all objects in memory
   TIter next(f.GetList());  //create an iterator to loop on list of objects
   TH1 *h;
   while (h=(TH1*)next()) {
      h->Print();
   }
}
An extension of solution 2 to generate a PostScript file for each histogram
in a ROOT file. Each file will get the corresponding histogram name:
{
   gROOT->Reset();
   TFile f("marek.root");
   f.Read();  // read all objects in memory
   c1 = new TCanvas("c1");
   TIter next(f.GetList());  //create an iterator to loop on list of objects
   TH1 *h;
   while (h=(TH1*)next()) {
      h->Draw();
      c1->Print(h->GetName());
   }
}
Rene Brun