Naming a canvas variable

Hi,

I have a question regarding basic programming skills.

In my Analyzing macro I want the canvas to be named one could imagine from looking at my code.
So it should be named c_intervallHist_2010_11_12
Only the date part should come from a variable named datensatzdatum, the rest is static.

This is a “trick” a friend of mine suggested but it is not working.
Here is the code

[code]//Events über Zeitintervall
char [80] datensatzdatum = “2010_11_12”;
char [100] c_intervallHist = “c_intervallHist_”+datensatzdatum;
TCanvas *c_intervallHist = new TCanvas(c_intervallHist, c_intervallHist,284,467,700,502);
c_intervallHist->Range(-3.764811,-66.46194,3.732495,573.7428);
c_intervallHist->SetBorderSize(2);
c_intervallHist->SetFrameFillColor(0);

TH1* intervallHist = new TH1D("Intervall","Zeit zwischen 2 Events",4096,0,200);
intervallHist->GetXaxis()->SetTitle("Zeit zwischen 2 Events [ms]");
intervallHist->GetYaxis()->SetTitle("number of events");
intervallHist->GetXaxis()->SetLabelSize(0.02);
intervallHist->GetYaxis()->SetLabelSize(0.02);

[/code]
When I execute the macro I get the following error

Maybe you can help?

Thank you.

Your code has several C++ errors, in particular you use the sane name for the character title and canvas pointer name. I have made some trivial changes such that at least your code executes.

Rene

[code]{
//Events uber Zeitintervall
TString datensatzdatum = “2010_11_12”;
TString c_intervallHist = “c_intervallHist_”+datensatzdatum;
TCanvas *c = new TCanvas(c_intervallHist, c_intervallHist,284,467,700,502);
c->Range(-3.764811,-66.46194,3.732495,573.7428);
c->SetBorderSize(2);
c->SetFrameFillColor(0);

TH1* intervallHist = new TH1D(“Intervall”,“Zeit zwischen 2 Events”,4096,0,200);
intervallHist->GetXaxis()->SetTitle(“Zeit zwischen 2 Events [ms]”);
intervallHist->GetYaxis()->SetTitle(“number of events”);
intervallHist->GetXaxis()->SetLabelSize(0.02);
intervallHist->GetYaxis()->SetLabelSize(0.02);
}
[/code]

I saw the mistake with the names after I posted it.
The problem was with char and some “”.

Your suggestion worked perfectly, thank you very much.