THStack GetXaxis Segmentation fault

Hello,
I am getting a segmentation error for calling GetXaxis with THStack. If I omit the portion with axis labelling the code compiles fine but as soon as I add it I get a segmentation error. I don’t see where my mistake is. Any help would be welcome.
Thanks
Sakib

[code]Print(THStack *hs, TCanvas *c, TLegend *leg, char *index, char *map, char *genname, char *type, Float_t off, int i, int l)
{

/---------------------------------Set Margin so that axis title and number labels don’t overlap.------------------------/
c->cd(l+1);
gPad->SetLeftMargin(0.15);

/------------------------------------Draw Histogram and Set Title--------------------------------------------------------/
hs->Draw(“nostack,e1p”);
hs->SetTitle(Form("%s %s for %s_%3.1f", genname, type, map, off));

/*--------------------------------------------------------------------------------------------------------------------------/

/-------------------------------Set x and y axis title-------------------------------/
char yLab[3][4][30]={“Rate [GHz/5mm]”,“Rate [GHz/0.2ppb]”,“Rate [GHz/0.3mdeg]”,“Rate [GHz/deg]”,
“Rate [GHz/5mm]”,“Rate [GHz/3ppb]”,“Rate [GHz/0.3mdeg]”,"",
“Rate [GHz/5mm]”,“Rate [GHz/5ppb]”,“Rate [GHz/0.3mdeg]”,""};
char xLab[4][30]= {“r [m]”,“A_{PV} [ppb]”,"#theta_{lab} [deg]","#theta_{com} [deg]"};
hs->GetYaxis()->SetTitle(yLab[i][l]);
hs->GetXaxis()->SetTitle(xLab[l]);
hs->GetYaxis()->CenterTitle();
hs->GetXaxis()->CenterTitle();
hs->GetXaxis()->SetTitleOffset(1.3);
hs->GetYaxis()->SetTitleOffset(1.8);
hs->GetXaxis()->SetNoExponent(kTRUE);
hs->GetYaxis()->SetNoExponent(kTRUE);

/--------------------------Set x and y axis title ------------------/

/----------------------------------Draw Legend, set canvas size and save as png----------------------------------------------/

gPad->Modified();
c->Update();
if(l==3)
{
leg->Draw();
c->Resize();
c->SetCanvasSize(1200,1200);
c->Print(Form("/w/halla/parity/disk2/rahmans/geocomp/%s_%s_%s_%3.1f.png", index, genname, map, off));
c->Modified();
c->Update();
leg->Clear();
leg->SetHeader(“Simulation-Geometry”);
}[/code]

Following up with the previous post, apparently if I replace the character arrays for axis labelling with pointers, the code works fine :confused:. It’s ugly but here is my working code. I am relatively amateur at working with pointers. Does anybody have a clue why this is happening?

[code]Print(THStack *hs, TCanvas *c, TLegend *leg, char *index, char *map, char *genname, char *type, Float_t off, int i, int l)
{

/---------------------------------Set Margin so that axis title and number labels don’t overlap.------------------------/
c->cd(l+1);
gPad->SetLeftMargin(0.15);
/gPad->SetRightMargin(0.12);
gPad->SetBottomMargin(0.12);
gPad->SetTopMargin(0.12);
/
/---------------------------------Order matters. Set the margin only after switching to the canvas.----------------------/

/------------------------------------Draw Histogram and Set Title--------------------------------------------------------/
hs->Draw(“nostack,e1p”);
hs->SetTitle(Form("%s %s for %s_%3.1f", genname, type, map, off));

/*--------------------------------------------------------------------------------------------------------------------------/

/-------------------------------Set x and y axis title-------------------------------/
char yLab[3][4][30]={“Rate [GHz/5mm]”,“Rate [GHz/0.2ppb]”,“Rate [GHz/0.3mdeg]”,“Rate [GHz/deg]”,
“Rate [GHz/5mm]”,“Rate [GHz/3ppb]”,“Rate [GHz/0.3mdeg]”,"",
“Rate [GHz/5mm]”,“Rate [GHz/5ppb]”,“Rate [GHz/0.3mdeg]”,""};
char xLab[4][30]= {“r [m]”,“A_{PV} [ppb]”,"#theta_{lab} [deg]","#theta_{com} [deg]"};
hs->GetYaxis()->SetTitle(
(yLab[0][0]+i
4+l));
hs->GetXaxis()->SetTitle(*(xLab[0]+l));
hs->GetYaxis()->CenterTitle();
hs->GetXaxis()->CenterTitle();
hs->GetXaxis()->SetTitleOffset(1.3);
hs->GetYaxis()->SetTitleOffset(1.8);
hs->GetXaxis()->SetNoExponent(kTRUE);
hs->GetYaxis()->SetNoExponent(kTRUE);

/--------------------------Set x and y axis title only after drawing the histogram because else you get an error------------------/

/----------------------------------Draw Legend, set canvas size and save as png----------------------------------------------/

gPad->Modified();
c->Update();
if(l==3)
{
leg->Draw();
c->Resize();
c->SetCanvasSize(1200,1200);
c->Print(Form("/w/halla/parity/disk2/rahmans/geocomp/%s_%s_%s_%3.1f.png", index, genname, map, off));
c->Modified();
c->Update();
leg->Clear();
leg->SetHeader(“Simulation-Geometry”);
}
/-----------------------------------------------------------------------------------------------------------------------------/

}[/code]