I have a txt file whose first line is:
I would like to read the "O2008bws.gif"string from my root script, writing it in the “plotname” string and save the plot produced by the root script with this name. I do in the following way, but it gives me errors:
Can anybody tell me where I’m wrong?
You probably meant
somehistogram->SaveAs(name)You also need to add some code to skip/remove the first characters (#). (name.erase(0,1); might work.)
thanks, but it still doesn’t work
I was meaning:
If [quote]name[/quote] is a string, I was expecting [quote]SaveAs(name)[/quote] working, while it tells to me it cannot call “TCanvas::SaveAs(name)” in current scope…
How can I give the name of the plot image without writing it explicitely within quotes?
If I add
name.erase(0,1) as I would like to do, it tells me “can’t call name.erase(0,1)”.
string name; the right way to define “name” as a string object?
Anar is correct. SaveAs takes as an argument a ‘const char*’ and std::string as no automatic converter to ‘const char*’, hence you must use the explicit call (canvas->SaveAs(name.c_str())