I write some object (of class TTree) to tree with this routine:
const unsigned char size = 5;
TString strings[size] = {"AA", "B2", "wwer", "yrty", "y6"};
TFile * treefile = TFile::Open("treefile.root", "RECREATE");
TTree * tree = new TTree("test", "test");
TString string;
tree -> Branch("string", &string);
for (unsigned char i = 0; i < size; i ++)
{
string = strings[i];
tree -> Fill();
}
tree -> Write();
treefile -> Close()
Then I reead the tree with this routine:
TFile * f = TFile::Open("treefile.root");
TTree * tree = (TTree *) f -> Get("test");
TString string;
tree -> SetBranchAddress("string", &string);
for (unsigned long i = 0; i < tree -> GetEntries(); i ++)
{
tree -> GetEntry(i);
printf("%lu %s\n", i, string.Data());
}
f -> Close();
However, I get an error:
Error in <TTree::SetBranchAddress>: The address for "string" should be the address of a pointer!
What is wrong?
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided