Hi,
I’m trying to create a TTree with a string in it, but the code keeps segfaulting. Here’s what I’m doing:
[code]#include <TTree.h>
#include
TTree* readLines() {
TTree* t = new TTree(“t”, “t”);
string name;
float b;
t->Branch(“name”, &name);
t->Branch(“b”, &b, “b/F”);
name = “test”;
b = 1;
t->Fill();
t->Scan(); // Success
return t;
}
void test() {
TTree* tLocal = readLines();
tLocal->Scan(); // Segfault
}
[/code]
.x test.C+ makes the code segfault when trying to scan the returned tree. Why is this happening?
N.