TTree::ReadFile & strings

Hi there,

I have a 2 column ascii file : the 1st is filled with doubles, the 2nd with strings.
I can get back the value of each doubles but don’t manage to get that of strings: TTree *tree = new TTree () ; tree->ReadFile("myfile.dat","mydouble/D:mystring/C") ; tree->GetEntry(0) ; printf ("\n%e\n",tree->GetLeaf("mydouble")->GetValue(0)) ; /// ...I’ve tried to use TLeafC which has a GetValueString() method, in vain.
Another solution seems to be using TLeaf::ReadValue(ifstream&) as one may suppose from reading the following post http://root.cern.ch/phpBB3//viewtopic.php?t=4664.
I cannot figure out how to proceed though. Could you please help me?

Cheers,
Z

Ooooops… :blush:
Could you, Mr Moderator, please move this post to the “ROOT Support” forum (or remove it completly, I’ll post it again properly)?
Sorry :unamused:
Z

Hi,

The easiest is to do:char *str = (char*)tree->GetLeaf("mystring")->GetValuePointer(); orchar *str = new char[256]; tree->SetBranchAddress("mystring",str);

Cheers,
Philippe.

:slight_smile:
Cheers Philippe