This is a small example using pointers to histograms.
{
// example of program creating, filling, saving hsitograms in a file
gROOT->Reset();
TFile hfile("hfile.root","RECREATE");
// create histograms
TH1S *h[16];
char name[20];
char title[100];
for (Int_t i=0;i<16;i++) {
sprintf(name,"h%d",i);
sprintf(title,"title of h%d",i);
h[i] = new TH1S(name,title,100,500,600);
}
// fill histograms
for (Int_t i=0;i<16;i++) {
for (Int_t j=0;j<1000;j++) {
Float_t x= gRandom->Rndm();
h[i]->Fill(500+100*x);
}
}
// save histograms
hfile.Write();
}
You can also look at the tutorials section at:
http://root.cern.ch/root/Tutorials.html
and in particular at:
http://root.cern.ch/root/html/examples/hsimple.C.html
http://root.cern.ch/root/html/examples/hsum.C.html
Rene Brun