Adding an array of char[] to a TTree

hi,
following the staff.C example, i would like to store, foreach event i record, an array of say 3 elements:
char Label[3][10];
Tree->Branch(“Label”,NNdata.Label,“Label[3]/C”)
sprintf(Label[0],“a”);
sprintf(Label[1],“b”);
sprintf(Label[2],“c”);

Tree.Fill()

but then, if i read back the TTree and scan the Label Branch,
Tree.Scan(‘Label[0]’)

it’s always set to ‘a’

how can i use array of strings (array of char) with ROOT /5.18?
thanks.

Hi,

I strongly suggest using C++ std::string or Root’s TString instead.

Cheers,
Charles

Hi,

char Label[3][10]; Tree->Branch("Label",NNdata.Label,"Label[3]/C"); The leaflist method does not support array of strings. This call to Branch creates a branch for one string of 2 characters per event.

[quote]how can i use array of strings (array of char) with ROOT /5.18? [/quote]In v5.18, you best bet is to use a TClonesArray of TObjString and/or one you class containing the strings.

Cheers,
Philippe.