Automatic save a histogram to a .C-file using script

Hi!

I’ve made an automatic script which takes a lot of files and plots histograms and saves them into .pdf-files nad .jpg files. I would also like to save them into .C-files (automatically). Does anyone no how to accomplish this?

I include my script for saving the pictures:

[code]while(there are more files) {

            //Do a lot of stuff
TCanvas* c0 = new TCanvas("c0","c0");


//Saving file as pdf
TString outputName = inFile + ".pdf";
TString fileType = "pdf";
c0->Print(outputName,fileType);

//Saving file as jpg
TString outputName2 = inFile + ".jpg";
TString fileType2 = "jpg";
c0->Print(outputName2,fileType2);

}[/code]

I have tried using the same method as above, with changing the fileType = “C”, but it wont work.

Does anyone know how to help me?

Thanks!

I suggest the following:

[code]while(there are more files) {
//Do a lot of stuff
TCanvas* c0 = new TCanvas(“c0”,“c0”);

//Saving file as pdf
c0->Print(Form(%s.pdf",inFile.Data()));

//Saving file as jpg
c0->Print(Form(%s.jpg",inFile.Data()));

//Saving file as C
c0->Print(Form(%s.C",inFile.Data()));
}[/code]

Rene