TPad Print with variables

Hello,
I am trying to store a number of canvases in a pdf file that needs to inherit a name from a histogram bin label. The string and const char* sets up fine, and the canvas definitely has a value stored to it, but when I try to print the pdf I get a seg fault.
This is what I am doing: [code]
const char* tagn=cuttags->GetXaxis()->GetBinLabel(j+1);
tagname.at(j)=tagn;
tagname.at(j);
std::transform(tagname.at(j).begin(), tagname.at(j).end(), tagname.at(j).begin(), [](char ch)
{return ch==’ ’ ? ‘_’ :ch;
});
string tago=tagname.at(j)+".pdf";
const char* tag=tago.c_str();
string closetag=tagname.at(j)+".pdf)";
string opentag=tagname.at(j)+".pdf(";
const char* ct=closetag.c_str();
const char* ot=opentag.c_str();
canvas[0][j]->Print(ot);
for (int i=1; i<10; i++)
{
canvas[i][j]->Print(tag);
}
canvas[10][j]->Print(ct);

[/code]
with the error happening at the first Print useage.
The first few lines of the stack trace are #5 0x00000030c08183f9 in FT_Done_Glyph () from /usr/lib64/libfreetype.so.6 #6 0x00007f2b009bf3f8 in TTF::LayoutGlyphs() () from /a/data/xenia/share/atlas/ATLASLocalRootBase/x86_64/root/6.04.16-x86_64-slc6-gcc49-opt/lib/libGraf.so #7 0x00007f2b009bffe3 in TTF::GetTextAdvance(unsigned int&, char*) () from /a/data/xenia/share/atlas/ATLASLocalRootBase/x86_64/root/6.04.16-x86_64-slc6-gcc49-opt/lib/libGraf.so

Is it possible to print canvases in this manner?

can you provide a small running script reproducing this issue ?

Sure, the problem is independent of the reading in of the string so I shall exclude that.

void Printcanvas(){
TCanvas * c1[10];
TH1F * h_test[10];
for(int i=0; i<10; i++)
{
	h_test[i]=new TH1F (Form("test_h_%d", i), "test hist", 10, -5, 5);
	h_test[i]->FillRandom("gaus", 1000);
	c1[i]=new TCanvas;
	c1[i]->cd();
	h_test->Draw();
}
string filename="test.pdf";
string openfile=filename+"(";
string closefile=filename+")";
const char* f=filename.c_str();
const char* of=openfile.c_str();
const char* cf=closefile.c_str();
c1[0]->Print(of);
for (int i=1; i<9; i++)
{
	c1[i]->Print(f);
}
c1[9]->Print(cf);
}

So this runs fine, but I do not see any fundamental difference from what I was doing before

We need an example reproducing the issue. If the last example you posted runs fine that does not help.

It appears as though the original code actually runs fine, as long as it is run in a different directory. As of such, I shall close this incident.