Help saving histogram arrays

I have to save a set of histogram arrays, but I cannot figure the exact code. The histogram array has already been defined without a problem. What I need to do is to save each histogram in the array to a seperate file. Here is the code, which I tried:
const char *file_name[20];
Int_t newfile;
for (int i=0; i<5; i++) {
c1->cd(); //c1 refers to my canvas
nb_cap_a_z[i]->Draw(); //This is the histogram array. 5 are in array.
newfile = sprintf (file_name, “file_aa_%u.C”,i);
c1->Print(file_name);
}
Is there a way to fix this set of code so that the c1->Print gives me automatically five .C files with the appropriate histogram from the array in there.

cpoole

It is not clear if you want to write the histogram or the canvas.
You can save any individual root object in various file formats using the
TObject::SaveAs function, see:http://root.cern.ch/root/html/TObject.html#TObject:SaveAs
Note that this function is available from the object context menu if the object is drawn in a pad.

For example you can save each of your 5 histograms in a separate file with
something like:

for (int i=0; i<5; i++) { nb_cap_a_z[i]->SaveAs(Form("file_aa_%d.C",i)); }

Rene

Thanks for your help.