TPad Print with variables

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);;;
std::transform(,,, [](char ch)
{return ch==’ ’ ? ‘_’ :ch;
const char* tag=tago.c_str();
const char* ct=closetag.c_str();
const char* ot=opentag.c_str();
for (int i=1; i<10; i++)

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/ #6 0x00007f2b009bf3f8 in TTF::LayoutGlyphs() () from /a/data/xenia/share/atlas/ATLASLocalRootBase/x86_64/root/6.04.16-x86_64-slc6-gcc49-opt/lib/ #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/

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;
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();
for (int i=1; i<9; i++)

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.