How to change folder where root saves canvases?

I made array of Canvases with For Loop:
TCanvas *Can[4];
Char_t *canvname = new Char_t[4];
for(Int_t a=1; a<5; a++){
Can[a]=new TCanvas(canvname,canvname,a);
This is how i get 4 separated Canvases (Canvas1, Canvas2, Canvas3, Canvas4).

Next I made 1 histogram in each of there Canvases,under same For Loop:
TH1 *h[4];
Char_t *histname = new Char_t[4];
h[a] = new TH1F(histname,histname,100,-3,3);
And I filled each histogram with some distribution, but thats not important now.

Now I saved each Canvas separately under same For Loop:
Char_t *ps_filename = new Char_t[4];
This way ROOT saves all 4 Canvases in /home folder. Its ROOT default folder for saving Canvas.

How can I specify folder where I wanna save these Canvases (for example in folder /home/nikola/Documents)?

I can save these canvases in folder that I want but outside For Loop like this:


But that isn’t point, i need to place Print command in For Loop.

Char_t *ps_filename = new Char_t[4]; sprintf(ps_filename,"/home/nikola/Documents/",a); Can[a]->Print(ps_filename);

How do I pack sizeof("/home/nikola/Documents/") bytes into a 4*sizeof(Char_t) long buffer :question: :-k
:bulb: I know, use “sprintf” :exclamation: \:D/


[quote=“pamputt”]Char_t *ps_filename = new Char_t[4]; sprintf(ps_filename,"/home/nikola/Documents/",a); Can[a]->Print(ps_filename);[/quote]

I already did same… and ROOT report error… now i copy/paste this and it works… I hate programming… #-o
Thank You all for help.